Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请高手指点一下,还有什么地方能优化的,为什么总是TLE...#include <stdio.h> #include <memory.h> int prime[]={2,3,5,7,11,13,17,19,23}; void fun(int n,int *a){ int i; for(i=0;i<9;i++) while(n%prime[i]==0){ n/=prime[i]; a[prime[i]]++; } if(n!=1) a[n]++; } int main(){ int a[432],b[432]; int i,n,k; _int64 s; while(scanf("%d %d",&n,&k)!=EOF){ memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); s=1; for(i=n;i>=n-k+1;i--) fun(i,a); for(i=2;i<=k;i++) fun(i,b); for(i=2;i<=n;i++) a[i]-=b[i]; for(i=2;i<=n;i++) if(a[i]!=0) s*=a[i]+1; printf("%I64d\n",s); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator