Divisors
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 9940   Accepted: 2924

Description

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 4

Sample Output

2
6
16
 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[]={},t,pp[];
void init()
{
int i,j;
t=;
for(i=; i<; i++)
{
if(!p[i])
{
p[t++]=i;
j=i*i;
while(j<)
{
p[j]=;
j+=i;
}
}
}
}
void fun(int n,int q)
{
int i,j,m,sum;
for(i=; p[i]<=n&&i<t; i++)
{
m=n;
sum=;
while(m)
{
m/=p[i];
sum+=m;
}
if(q)
pp[i]+=sum;
else pp[i]-=sum;
}
}
int main()
{
init();
int n,k,i;
while(~scanf("%d%d",&n,&k))
{
memset(pp,,sizeof(pp));
fun(n,);
fun(k,);
fun(n-k,);
long long sum=;
for(i=; i<t; i++)
{
if(pp[i])sum*=pp[i]+;
}
printf("%lld\n",sum);
}
}

Divisors poj2992的更多相关文章

  1. POJ2992:Divisors(求N!因子的个数,乘性函数,分解n!的质因子(算是找规律))

    题目链接:http://poj.org/problem?id=2992 题目要求:Your task in this problem is to determine the number of div ...

  2. 【POJ2992】Divisors

    [题目概括] 计算\(C_n^k\)的因子个数. [思路要点] 首先考虑将组合数展开,展开后就是\(\frac {n!}{k!\times (n-k)!}\). 这样就是计算出这些质因子的个数,然后将 ...

  3. codeforces 27E Number With The Given Amount Of Divisors

    E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...

  4. HDU - The number of divisors(约数) about Humble Numbers

    Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence ...

  5. Divisors

    计算小于n的数中,约数个数最多的数,若有多个最输出最小的一个数. http://hihocoder.com/problemset/problem/1187 对于100有 60 = 2 * 2 * 3 ...

  6. Xenia and Divisors

    Xenia and Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. hihocoder1187 Divisors

    传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given an integer n, for all integers not larger than n, f ...

  8. The number of divisors(约数) about Humble Numbers[HDU1492]

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  9. Sum of divisors

    Problem Description mmm is learning division, she's so proud of herself that she can figure out the ...

随机推荐

  1. FileProvider解决FileUriExposedException

    FileUriExposedException 在给app做版本升级的时候,先从服务器下载新版本的apk文件到sdcard路径,然后调用安装apk的代码,一般写法如下: private void op ...

  2. 单表ORM框架

    基本描述 1.首先是一个单表的ORM框架,多表连接查询请使用视图或者使用SqlHelper查询,然后转换成实体集合. 2.目前仅完成基本结构和MySQL部分. 3.目前欠缺Lambda表达式解析,所以 ...

  3. window.onerror 应用实例

    详见: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp75   window.onerror = function(sMessa ...

  4. js并行加载,顺序执行

    js并行加载,顺序执行 <script>运行脚本或加载外部文件时,会阻塞页面渲染,阻塞其他资源的加载.如果页面中需要加载多个js文件,在古老浏览器中性能会比较糟糕. 因此有了最原始的优化原 ...

  5. ROS学习记录(一)————创建简单的机器人模型smartcar

    这是我在古月居上找的(http://www.guyuehome.com/243),但直接运行的话,没办法跑起来,我也是查了好多博客和日志,才实现最后的功能的,所以,记录下来,以备后用吧,也欢迎其他和我 ...

  6. 闭锁——CountDownLatch

    一.概念 闭锁是一个同步工具类,主要用于等待其他线程活动结束后,再执行后续的操作.例如:在王者荣耀游戏中,需要10名玩家都准备就绪后,游戏才能开始. CountDownLatch是concurrent ...

  7. js函数防抖、节流实现

    防抖 Debounce 函数防抖就是,延迟一段时间再执行函数,如果这段时间内又触发了该函数,则延迟重新计算: // 简单实现 function debounce(fn, wait) { let t r ...

  8. NWERC2016-Problem A(Arranging Hat)

    Arranging Hat is a cushy job indeed; high impact work, absolute authority, and 364 days of holiday e ...

  9. 团队作业8----第二次项目冲刺(Beta阶段) 第六天

    BETA阶段冲刺第六天 1.小会议ing 2.每个人的工作 (1)昨天已完成的工作 重复部分可以用红色字体显示 (2) 今天计划完成的工作 (3) 工作中遇到的困难: 尤少辉:在测试的时候,当队友提出 ...

  10. 201521123082 《Java程序设计》第9周学习总结

    201521123082 <Java程序设计>第9周学习总结 标签(空格分隔):java 1.本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 2. 书面作业 ...