Your task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful computation?

Input

The input consists of several instances. Each instance consists of a single line containing two integers n and k (0 ≤ k ≤ n ≤ 431), separated by a single space.

Output

For each instance, output a line containing exactly one integer -- the number of distinct divisors of Cnk. For the input instances, this number does not exceed 2 63 - 1.

Sample Input

5 1
6 3
10 4

Sample Output

2
6
16 思路:求因数个数,想到唯一分解定理
p = a1^s1+a2^s2+...., 因子总数=(s1+1)(s2+1)..... 每次都计算组合数再计算因子数显然会超时,范围只有431,可以预处理
先预处理出质数,由C[n][m] = n!/m!(n-m)!, 将每个阶乘中的质因子次数求出来,例如对于n!,求质数i的次数 = n/i+n/i^2+n/i^3+....
递推优化, a = n/i+n/i^2+...., b = a / i = n/i^2+n/i^3+....
typedef long long LL;
typedef pair<LL, LL> PLL; const int maxm = ; bool prime[maxm];
int num[maxm][maxm];
int jud[maxm], siz = ;
LL C[maxm][maxm]; void getprime() {
for(int i = ; i * i <= maxm; ++i) {
if(!prime[i]) {
for(int j = i*i; j <= maxm; j += i)
prime[j] = true;
}
}
for(int i = ; i <= maxm; ++i)
if(!prime[i]) {
jud[siz++] = i;
}
for(int i = ; i < siz; ++i) {
for(int j = ; j <= maxm; ++j)
num[j][i] = j/jud[i] + num[j/jud[i]][i];
}
for(int i = ; i <= maxm; ++i) { // C[i][j]
for(int j = ; j < i; ++j) {
C[i][j] = ;
for(int k = ; k < siz; ++k) {
int d = num[i][k] - num[i-j][k] - num[j][k];
if(d) C[i][j] *= (d+);
}
}
}
} int main() {
getprime();
int n, k;
while(scanf("%d%d", &n, &k) != EOF) { // C(n, k) n!/k!(n-k)!
if(n == k || k == )
printf("1\n");
else
printf("%lld\n", C[n][k]);
}
return ;
}
												

最新文章

  1. Matlab中double,im2double,mat2gray区别
  2. 本地json文件的编辑器,node-webkit开发的exe程序
  3. Codeforces Round #184 (Div. 2) E. Playing with String(博弈)
  4. POJ 2559 Largest Rectangle in a Histogram
  5. Android 中的Force Close
  6. BZOJ1576 [Usaco2009 Jan]安全路经Travel
  7. tortoiseGit的SHH秘钥设置
  8. async 与 await异步编程活用基础
  9. jQuery.YesShow - 图片轮播插件(带图片放大功能)
  10. Oracle_Q&amp;A_02
  11. js五种设计模式
  12. 【HTML】dl dt dd
  13. Tensorflow环境下安装Pandas
  14. A - Brackets POJ - 2955 (区间DP模板题)
  15. CentOS6.5 上crontab每天自动备份mysql数据库
  16. Appium介绍及工作原理
  17. CorelDRAW(cdr) 2018安装教程详解
  18. 绘图QPainter-字体
  19. vs 2012/2013 等工具中,使用正则表达式,查找、替换
  20. 编写安全的API接口

热门文章

  1. android 支持上拉加载,下拉刷新的列表控件SwipeRefreshLayout的二次封装
  2. selenium webdriver 操作RadioButton
  3. PAT T1024 Currency Exchange Centers
  4. PAT A1114 Family Property
  5. RESTful风格化
  6. vuetify &amp; electron (开发环境及打包)
  7. html常用整理
  8. redis5.0版本集群搭建
  9. HTML5画的简单时钟
  10. kubernetes 1.5.2 部署kube-dns 踩过的坑