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:IC0500510080 at 2005-12-25 17:25:09 #include<stdio.h> void main() { int n,k,m; scanf("%d",&n); for(int i=0;;i++) { if((i*(i+1)/2)>=n) {k=i*(i+1)/2;break;} } if(k==n)m=i; else if((k-n)%2==1&&i%2==1)m=i+2; else if((k-n)%2==1&&i%2==0)m=i+1; else if((k-n)%2==0)m=i; printf("%d\n",m); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator