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> int main() { int i,j,k,m,n,sum,save,m0; scanf("%d",&n); for(k=1;k<=n;k++) { sum=0; scanf("%d",&m); if(m==1){printf("%d %d %d\n",k,1,3);continue;} for(i=2;i<=m;i++) { m0=i; save=m0; if(m0%2==0)save/=2; while(m0%2==0)m0/=2; for(j=3;m0!=1;j+=2) { if(m0%j==0)save=save/j*(j-1); while(m0%j==0)m0/=j; } sum+=save; } printf("%d %d %d\n",k,m,2*sum+3); }//for }//main Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator