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 |
Re:为什么我这么做就老是超时?In Reply To:为什么我这么做就老是超时? Posted by:myi_i at 2004-09-27 15:46:57 #include<stdio.h> main() { int i,n,r; while(scanf("%d",&n)!=EOF) { r=0; for(i=1;;i++) { r+=i; if(r>=n) break; } if((r-n)%2) { if(i%2) i+=2; else i+=1; } printf("%d\n",i); } } //一句话,找规律 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator