标签:个数 max ber code pac style ted clu break
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 12085 | Accepted: 3600 |
Description
Input
Output
Sample Input
5 1 6 3 10 4
Sample Output
2 6 16
Source
1 #include "bits/stdc++.h" 2 using namespace std; 3 typedef long long LL; 4 const int MAX=435; 5 int n,m,len,pri[MAX];LL ans[MAX][MAX]; 6 bool t[MAX]; 7 void prime(){ 8 register int i,j; 9 memset(t,true,sizeof(t)); 10 for (i=2;i<MAX;i++){ 11 if (t[i]) pri[++len]=i; 12 for (j=1;j<=len && pri[j]*i<MAX;j++) {t[pri[j]*i]=false; if (i%pri[j]==0) break;} 13 } 14 } 15 inline int calc(register int x,register int y){ 16 register int an=0; 17 while (x){an+=x/y;x/=y;} 18 return an; 19 } 20 int main(){ 21 freopen ("divisors.in","r",stdin);freopen ("divisors.out","w",stdout); 22 register int i,j,k; 23 prime();ans[0][0]=1; 24 for (i=1;i<MAX;i++){ 25 ans[i][i]=ans[i][0]=1; 26 for (j=1;j<i;j++){ 27 ans[i][j]=1; 28 for (k=1;k<=len;k++) 29 ans[i][j]*=calc(i,pri[k])-calc(j,pri[k])-calc(i-j,pri[k])+1; 30 } 31 } 32 while (~scanf("%d%d",&n,&m)) printf("%lld\n",ans[n][m]); 33 return 0; 34 }
标签:个数 max ber code pac style ted clu break
原文地址:http://www.cnblogs.com/keximeiruguo/p/7811308.html