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. Java面试准备之探究集合

    摘要:之前虽然对集合框架一些知识点作了总结,但是想想面试可能会问源码,于是又大致研究了一下集合框架的一些实现类的源码,在此整理一下. 一.集合框架 二.深究实现类 1.ArrayList源码实现 Ar ...

  2. python 关于列表的增删改查及个别的命令

    names = ["a","b","c","d","e","e","a ...

  3. java多线程sleep和wait方法的区别

    分别创建了三个类,一个测试类,两个线程类实现Runnable接口. 当有notify()唤醒线程时,执行的结果如下: 当把TestSleepaWait.class.notify();语句注释后,即没有 ...

  4. Spring Aop 应用实例与设计浅析

    0.代码概述 代码说明:第一章中的代码为了突出模块化拆分的必要性,所以db采用了真实操作.下面代码中dao层使用了打印日志模拟插入db的方法,方便所有人运行demo. 1.项目代码地址:https:/ ...

  5. log4j使用和配置详解

    日志是应用软件中不可缺少的部分,Apache的开源项目Log4j是一个功能强大的日志组件,提供方便的日志记录.以下是个人经验,具体请参考Log4j文档指南. Log4j下载 在apache网站:htt ...

  6. Java面试系列之HashMap大扫盲汇总

    PS:整理的稍微有点急,不足之处,望各路道友指正,List相关可以查看前一篇随笔! HashMap的工作原理是近年来常见的Java面试题,几乎每个Java程序员都知道HashMap,都知道哪里要用Ha ...

  7. webpack配置这一篇就够

    最近看了一篇好文,根据这个文章重新梳理了一遍webpack打包过程,以前的一些问题也都清楚了,在这里分享一下,同时自己也做了一些小的调整 原文链接:http://www.jianshu.com/p/4 ...

  8. JS中的运算符和JS中的分支结构

    JS中的运算符 1.算术运算(单目运算符) + .-.*. /. %取余.++自增 .--自减 +:两种作用,链接字符串/加法运算.当+两边全为数字时,进行加法运算:当+两边有任意一边为字符串时,起链 ...

  9. Java语言课程设计——博客作业教学数据分析系统(201521123107 张翔)

    #Java语言课程设计--博客作业教学数据分析系统(个人博客) 1.团队课程设计博客链接 [博客作业教学数据分析系统(From:网络五条狗)](http://www.cnblogs.com/fanta ...

  10. 201521123073 《Java程序设计》第11周学习总结

    1. 本周学习总结 2. 书面作业 本次PTA作业题集多线程 1.互斥访问与同步访问 完成题集4-4(互斥访问)与4-5(同步访问) 1.1 除了使用synchronized修饰方法实现互斥同步访问, ...