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 |
为什么是Time Limit Exceeded?帮帮忙看一下,谢谢!#include<stdio.h> #include<math.h> void main(){ int a,b,t,s, k; scanf("%d",&t); while(t!=0){ if(t==1)printf("TERM %d IS %d/%d\n",1,1,1); if(t==2)printf("TERM %d IS %d/%d\n",2,1,2); for(a=1;a<t;a++){ for(b=1;b<t;b++){ if((a+b)%2==1){s=a; for(k=1;k<(a+b-1);k++){ s+=k; } if(s==t) printf("TERM %d IS %d/%d\n",t,a,b); } else{s=b; for(k=1;k<(a+b-1);k++){ s+=k; } if(s==t) printf("TERM %d IS %d/%d\n",t,a,b); } } } scanf("%d",&t); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator