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 |
咳什么都不说了In Reply To:怎么还是WA呢?想不通啊 Posted by:Essence_me at 2005-09-10 11:30:55 > #include <stdio.h> > #include <math.h> > #include <stdlib.h> > #include <memory.h> > int num[100000],max; > void work(int i) > { > int sum=0; > while(i>0) > { > sum+=i%10; > i/=10; > } > num[sum]++; > if(sum>max)max=sum; > } > > int main() > { > int k1,k2,n,i; > long sum; > scanf("%d",&n); > max=0; > memset(num,0,sizeof(int)*((int)exp(n/2*log(10))-1)); > for(i=0;i<exp((n/2)*log(10))-1;i++) > { > work(i); > } > sum=0; > for(i=0;i<=max;i++) > { > sum+=num[i]*num[i]; > } > printf("%ld\n",sum); > system("PAUSE"); > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator