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 |
超级无敌大水题啊,不过都对不起自己,哈哈#include <stdio.h> int main() { int s,n,d; while(scanf("%d",&s)!=EOF) { for(n=1;; n++) { if(n*(n+1)/2==s) { printf("%d\n",n); break; } else if(n*(n+1)/2>s) { d=n*(n+1)/2-s; if(d%2!=0) continue; else d/=2; if(d>=1) printf("%d\n",n); break; } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator