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 |
还是很水的嘛!21行0Ms AC了,哇咔咔咔哈哈哈~~~//找找规律嘛!把每个斜行单独放一堆,规律就出来了~ #include<stdio.h> int main() { int n,i,k=0,sum; while(~scanf("%d",&n)) { sum=0; for(i=1;;i++) { sum+=i; if(sum>=n) break; } sum-=i; if(i%2==0) printf("TERM %d IS %d/%d\n",n,n-sum,sum+i+1-n); else printf("TERM %d IS %d/%d\n",n,i+sum-n+1,n-sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator