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:思路是对的,怎么就是老给我“wrong answer”呢? 高人给看看吧!

Posted by fantasyorg at 2007-06-18 21:17:52 on Problem 1657
In Reply To:思路是对的,怎么就是老给我“wrong answer”呢? 高人给看看吧! Posted by:cpp0600548137 at 2006-02-26 21:35:46
#include<iostream>
using namespace std;

int mm(int, int);

int main()
{
	int times, d1, d2;
	char a[3], b[3];
	
	cin >> times;
	for (int i = 1; i <= times; i ++)
	{
		cin >> a >> b;
		d1 = mm (int(a[0]) , int(b[0]));
		d2 = mm (int(a[1]) , int(b[1]));
		
		if (d1 == 0 && d2 == 0)
			cout << 0 << ' ' << 0 << ' ' << 0 << ' ' << 0 << endl;
		else
		{
			cout << (d1 > d2 ? d1 : d2) << ' ';
			if (d1 == d2 || d1 == 0 || d2 == 0)
				cout << 1 << ' ';
			else
				cout << 2 << ' ';
		
			if (d1 == 0 || d2 == 0)
				cout << 1 << ' ';
			else
				cout << 2 << ' ';
		
			if (d1 == d2 && d1 != 0)
				cout << 1 ;
			else if (mm(d1 , d2) % 2 == 0)
				cout << 2;
			else
				cout << "Inf";
			cout << endl;
		}
		
	}
}

int mm(int a, int b)
{
	if (a > b)
		return a - b;
	else
		return b - a;
}

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