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

sum和difference 不同奇同偶时是impossible的

Posted by zzningxp at 2005-12-04 17:39:53 on Problem 2301
In Reply To:Re:错了,又错了,还是错了...为什么总是wrong answer? Posted by:Maxempire at 2005-12-04 17:37:39
> 这是源程序,请哪位牛人解决一下?
> #include<stdio.h>
> #include<math.h>
> void main(){
> 	int m,i,a,b,sum,difference;
> 	scanf("%d",&m);
> 	for(i=0;i<m;i++){
> 		scanf("%d %d",&sum,&difference);
> 		if(sum<0||difference<0){
> 			printf("impossible\n");
> 			continue;
> 		}
> 		a=(sum+difference)/2;
> 		b=(sum-difference)/2;
> 		if(a<0||b<0){
> 			printf("impossible\n");
> 			continue;
> 		}
> 		printf("%d %d\n",a,b);
> 	}
> }

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