版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qkoqhh/article/details/81951072
然后就可以对组合数做一下素数幂分解求τ(n)就可以了。。然后在线做会T。。要离线预处理。。
跑得好慢。。。
/**
* ┏┓ ┏┓
* ┏┛┗━━━━━━━┛┗━━━┓
* ┃ ┃
* ┃ ━ ┃
* ┃ > < ┃
* ┃ ┃
* ┃... ⌒ ... ┃
* ┃ ┃
* ┗━┓ ┏━┛
* ┃ ┃ Code is far away from bug with the animal protecting
* ┃ ┃ 神兽保佑,代码无bug
* ┃ ┃
* ┃ ┃
* ┃ ┃
* ┃ ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━━━━━━━━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1LL<<(x))
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 432
#define nm 200005
#define N 40005
#define M(x,y) x=max(x,y)
const double pi=acos(-1);
const int inf=1e9;
using namespace std;
ll read(){
ll x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f*x;
}
int c[84],tot,_x,_y,cnt[84];
vector<int>a[NM],b[NM];
ll d[NM][NM];
void init(){
inc(i,2,431){
bool f=true;
inc(j,1,tot)if(i%c[j]==0)f=false;
if(f)c[++tot]=i;
}
inc(i,2,431){
int t=i;
inc(j,1,tot)if(t%c[j]==0){
a[i].push_back(j);
int s=0;
while(t%c[j]==0)s++,t/=c[j];
b[i].push_back(s);
}
}
inc(n,0,431)inc(k,0,n/2){
mem(cnt);
inc(i,k+1,n){
int m=b[i].size()-1;
inc(j,0,m)cnt[a[i][j]]+=b[i][j];
}
inc(i,1,n-k){
int m=b[i].size()-1;
inc(j,0,m)cnt[a[i][j]]-=b[i][j];
}
d[n][k]=1;
inc(i,1,tot)d[n][k]*=cnt[i]+1;
d[n][n-k]=d[n][k];
}
}
int main(){
init();
while(~scanf("%d%d",&_x,&_y))printf("%lld\n",d[_x][_y]);
return 0;
}
Divisors
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 Sample Output Source |