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:yiyiyi4321的解法说明In Reply To:yiyiyi4321的解法说明 Posted by:level at 2006-08-06 21:15:40 > 1+2+3+4+5+6+7+8+9+10....因为在A中少加一数X(只能有+,-不加必减)相当于A-2X=B; > 要让X存在.A-B必为偶数.只要有一数A能减去给出的数B的结果C为偶数的话就一定可了. > #include<iostream.h> > void main() > { > int n,i,sum; > cin>>n; > sum=0; > for(i=1;sum<n||((sum-n)%2==1);i++)//小于||相差为奇数 > sum+=i; > cout<<i-1<<endl; > } 赞一个啊~~~~~~~~~~ 太NB了 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator