啊啊啊求c(n,k)
来源:互联网 发布:义乌淘宝村 编辑:程序博客网 时间:2024/05/23 13:37
poj 1306 Combinations
下面给出两种方法^-^(都AC!!!)
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>using namespace std;#define For(i, a, b) for(int i = a; i <= b; i++)#define ULL unsigned long longULL C(int k, int n){ULL ret = 1LL;For(i, 1, k)ret = (ret*(n-i+1))/i;return ret;}int main(){int n, k;while(scanf("%d%d", &n, &k) != EOF){if(!n && !k) break;int tmp = n-k, rk = k;k = min(tmp, k);printf("%d things taken %d at a time is %llu exactly.\n", n, rk, C(k, n));}return 0;}
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>using namespace std;#define Forr(i, a, b) for(int i = a; i >= b; i--)#define ULL unsigned long longULL C(int k, int n){ULL ret = 1LL;int j = 2;Forr(i, n, n-k+1){ret *= i;while(ret % j == 0 && j <= k) ret /= j++;}return ret;}int main(){int n, k;while(scanf("%d%d", &n, &k) != EOF){if(!n && !k) break; int rk = k;int tmp = n-k;k = min(tmp, k);printf("%d things taken %d at a time is %llu exactly.\n", n, rk, C(k, n));}return 0;}
1 0
- 啊啊啊求c(n,k)
- 啊啊啊啊啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊啊啊
- 啊啊啊啊啊啊啊
- 求访问啊啊啊啊
- 啊啊啊啊啊啊啊啊啊啊啊
- POJ 2249 Binomial Showdown 求组合数C(n,k)
- K&R《C程序设计语言》p17:求m的n次方
- 排序啊啊啊啊啊啊啊
- sci-ei求中啊啊啊
- 啊啊啊啊啊
- 开源代码Hadoop NFS connector (链接分享)
- 大型多人在线游戏服务器架构设计 - RPC封装原理
- 进程间的通信方式
- HDU-5584 LCM Walk(GCD/LCM+找规律)
- 用SQL*PLUS创建网页
- 啊啊啊求c(n,k)
- 图之 邻接表 邻接矩阵 结构体定义
- redis学习教程
- centos php扩展开发流程
- 九、递归和分治思想
- DM9000网卡驱动
- Unity中利用A*算法实现简单寻路
- C++栈的地址变化
- ubuntu安装程序时遇到错误 you might want to run 'apt-get -f install' to correct these