Time Limit: 5000 ms    Memory Limit: 10000 kB  
Total Submit : 432 (78 users)   Accepted Submit : 108 (57 users)   Page View : 3479  Font Style: Aa Aa Aa
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 263 - 1.
Sample Input
5 1
6 3
10 4Sample Output
2
6
16

代码如下:12=2^2*3^1 因子个数就等于(2+1)*(1+2)=12

#include<iostream>
#include<cstdio>
using namespace std;
int num;
bool a[]; struct prime
{
int num;
int count;
}p[]; void init()
{
int i,j;
memset(a,true,sizeof(a));
num=;
for(i=;i<;i++)
{
if(a[i]) p[num++].num=i;
for(j=;j<num&&i*p[j].num<;j++)
{
a[p[j].num*i]=;
if(i%p[j].num==)
break;
}
}
} __int64 Deal(int n,int m)
{
int i,j;
int a,b;
__int64 sum=;
if(m*<n)
a=n,b=n-m;
else
a=n,b=m;
for(i=;i<num;i++)
p[i].count=;
for(i=b+;i<=a;i++)
{
int t=i;
for(j=;p[j].num<=i && j<num && t!=;j++)
{
while(t%p[j].num==)
{
t/=p[j].num;
p[j].count++;
}
}
}
for(i=;i<=a-b;i++)
{
int t=i;
for(j=;p[j].num<=i && j<num && t!=;j++)
{
while(t%p[j].num==)
{
t/=p[j].num;
p[j].count--;
}
}
}
for(i=;i<num;i++)
{
if(p[i].count)
sum*=(p[i].count+);
}
return sum;
} int main()
{
int n,m;
init();
while(cin>>n>>m)
printf("%I64d\n",Deal(n,m));
return ;
}

Nk 1430 Divisors(因子数与质因数)的更多相关文章

  1. HDU6069:Counting Divisors(因子数统计|区间筛)

    题意 计算\(\sum_{i=l}^kd(i^k)(d_i代表i的因子数)\) 分析 比赛搞了3个小时都没搞出来,有两个思维上的trick 1.要先遍历素数,再遍历[L,R],而不是枚举每个数,然后对 ...

  2. Nk 1430 Fibonacci(二分矩阵乘幂)

    AC代码: #include<iostream> using namespace std; ][]; ][]; ][]; ][]; void binary(int n) { int i,j ...

  3. 从“n!末尾有多少个0”谈起

    在学习循环控制结构的时候,我们经常会看到这样一道例题或习题.问n!末尾有多少个0?POJ 1401就是这样的一道题. [例1]Factorial (POJ 1401). Description The ...

  4. Day 2 T1

    题目描述 组合数表示的是从n个物品中选出m个物品的方案数.举个例子,从(1,2,3) 三个物品中选择两个物品可以有(1,2),(1,3),(2,3)这三种选择方法.根据组合数的定 义,我们可以给出计算 ...

  5. 2017ACM暑期多校联合训练 - Team 4 1003 HDU 6069 Counting Divisors (区间素数筛选+因子数)

    题目链接 Problem Description In mathematics, the function d(n) denotes the number of divisors of positiv ...

  6. HDU 6069 Counting Divisors(唯一分解定理+因子数)

    http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意: 思路: 根据唯一分解定理,$n={a_{1}}^{p1}*{a2_{}}^{p2}...*{a_{ ...

  7. A - Divisors POJ - 2992 (组合数C的因子数)数学—大数

    题意:就是求组合数C的因子的个数! 先说一下自己THL的算法,先把组合数求出来,然后将这个大数分解,得到各个素数的个数,再利用公式!用最快的大数分解算法 分析一下时间复杂度!   n1/4但是分析一下 ...

  8. 【线性筛】【质因数分解】【约数个数定理】hdu6069 Counting Divisors

    d(x)表示x的约数个数,让你求(l,r<=10^12,r-l<=10^6,k<=10^7) #include<cstdio> using namespace std; ...

  9. hdu-1492 The number of divisors(约数) about Humble Numbers---因子数公式

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1492 题目大意: 给出一个数,因子只有2 3 5 7,求这个数的因子个数 解题思路: 直接求出指数即 ...

随机推荐

  1. 洛谷 P1996 约瑟夫问题

    题目背景 约瑟夫是一个无聊的人!!! 题目描述 n个人(n<=100)围成一圈,从第一个人开始报数,数到m的人出列,再由下一个人重新从1开始报数,数到m的人再出圈,……依次类推,直到所有的人都出 ...

  2. UIButton Making the hit area larger

    http://stackoverflow.com/questions/808503/uibutton-making-the-hit-area-larger-than-the-default-hit-a ...

  3. 访问修饰符(C# 参考)

    第一篇 就抄写了一下下MSDN上面的东西练练手吧!!! 访问修饰符是一些关键字,用于指定声明的成员或类型的可访问性.             本节介绍四个访问修饰符: public protected ...

  4. 程序windows上可以上传附件,部署到 linux服务器后出现 “上传目录 不可写” 怎么解决?

    这样的问题一般都是linux  下文件读写权限引起的,用 shell  命名到上传附件的目录(如 cd /data/www/project/upload/),然后执行 shell 文件权限设置: 例如 ...

  5. 关于HTML5中Video标签无法播放mp4的解决办法

    1.首先先排除掉代码问题.路径问题.浏览器不支持问题等常规问题,这些问题另行百度. <video width="500px" height="300px" ...

  6. iOS5 and iOS6都只支持横屏的方法

    If your app uses a UINavigationController, then you should subclass it and set the class in IB. You ...

  7. Django auth权限

    创建超级管理员命令 python manage.py createsuperuser --username hello 检查和校验用户 from django.contrib import auth ...

  8. readystatechange

    // alternative to DOMContentLoaded document.onreadystatechange = function () { if (document.readySta ...

  9. 【page-monitor 前端自动化 下篇】 实践应用

    转载文章:来源(靠谱崔小拽) 通过page-diff的初步调研和源码分析,确定page-diff在前端自动化测试和监控方面做一些事情.本篇主要介绍下,page-diff在具体的实践中的一些应用 核心d ...

  10. Web开发面临的挑战主要有哪些?

    摘要:要成为一名高效的Web开发者,这需要我们做很多工作,来提高我们的工作方式,以及改善我们的劳动成果.而在开发中难免会遇到一些困难,从前端到后端. 导读:要成为一名高效的Web开发者,这需要我们做很 ...