Divisors
Time Limit: 1000MS | Memory Limit: 65536K |
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 2
63 - 1.
Sample Input
5 1 6 3 10 4
Sample Output
2 6 16
#include<cstdio>
using namespace std;long long zu[432][432];
int jie[440][86]={0},n,x;
int main()
{
bool boo[440]={0};
int p[85],k=0,i,j;
for(i=2;i<440;i++)
{
if(!boo[i])p[k++]=i;
for(int j=0;j<k&&i*p[j]<440;j++)
{
boo[i*p[j]]=1;
if(!i%p[j])break;
}
}
for(int i=0;i<k;i++)for(int j=2;j<440;j++)jie[j][i]=j/p[i]+jie[j/p[i]][i];
for(i=2;i<432;i++)for(j=1;j<i;j++)
{
zu[i][j]=1;
for(int i1=0;i1<k&&jie[i][i1];i1++)
{
int side=jie[i][i1]-jie[j][i1]-jie[i-j][i1];
if(side)zu[i][j]*=(side+1);
}
}
while(scanf("%d%d",&n,&x)!=-1)
{
if(x==0||x==n)printf("1\n");
else printf("%I64d\n",zu[n][x]);
}
return 0;
}