Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:yiyiyi4321的解法说明

Posted by zhangliqiang at 2007-09-19 13:36:07 on Problem 1844
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;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator