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. pyhton安装pillow问题解决

    最近在学习Python的微信处理相关,因wxpy库中的微信客户端需要接收二维码需要安装pillow,如下 class wxpy.Bot(cache_path=None, console_qr=Fals ...

  2. [2016-07-15]结合命令行工具awk和多行文本编辑器快速生成DataSeed代码

    目标:根据业务提供的两份数据,生成DataSeed代码 SampleDataA 上海 华东一线 上饶 华东四线 中山 华南二线 临汾 华北四线 临沂 华东二线 SampleDataB 上海 1D04E ...

  3. firebird常用语句

    分页写法小例 SELECT FIRST templateid,code,name FROM template ; SELECT FIRST SKIP templateid,code,name FROM ...

  4. vue-router的两种模式的区别

    众所周知,vue-router有两种模式,hash模式和history模式,这里来谈谈两者的区别. ### hash模式 hash模式背后的原理是`onhashchange`事件,可以在`window ...

  5. MySQL的简单使用-(一)

    MySQL的简单使用 使用MySQL命令行工具 Windows 用户使用: MySQL Client, 输入密码 Linux: mysql -u用户名 -p密码 mysql -uroot -p 显示数 ...

  6. JS中的函数和BOM

    文档注释:开头两个*.写在函数上方,在调用函数时, 可以看到文档中的描述信息:function aaa(){ } [函数的声明及调用] 1.函数的声明格式: function 函数名(参数1,参数2, ...

  7. input[type="button"]与<button>的区别

    <button>标签  浏览器支持  所有主流浏览器都支持<button>标签.  重要事项:如果在HTML表单中使用button元素,不同的浏览器会提交不同的值.IE将提交& ...

  8. 实现点击后创建div,若对div2秒无操作则将div隐藏,鼠标移上div让它不隐藏,移出div超过两秒则div隐藏

    $('.addLabel').on('click', function () { setTimeout(function(){ if(hoverflag==0){ $(".labelHide ...

  9. Unity3d&C#分布式游戏服务器ET框架介绍-组件式设计

    前几天写了<开源分享 Unity3d客户端与C#分布式服务端游戏框架>,受到很多人关注,QQ群几天就加了80多个人.开源这个框架的主要目的也是分享自己设计ET的一些想法,所以我准备写一系列 ...

  10. 关于C语言

    对于C语言方面 觉得自己在数组方面比较薄弱,寒假之前也借了一些书关于C语言的希望能在家里好好看看,也看了差不多两三百页,视频没怎么看,看了七八集,希望学一些深入的语法或者说是算法.