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

救命啊!所有想到的数据试过了都对,就是通不过。

Posted by mashimarro at 2006-02-24 22:13:56 on Problem 1013
各位走过路过的大虾,牛人,强人,好心人,想攒rp的都来看吧,程序附在下面,一下午都没查出错来。先谢过了!
#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;
void main()
{
	char left[3][7],right[3][7],result[3][5];
	int let[12]={0,0,0,0,0,0,0,0,0,0,0,0};
	int i,t,j,k,p=0,coin=0;
	cin>>t;
	for (k=1;k<=t;k++)
	{
		int p=0,coin=0;
		for (j=0;j<3;j++)
			cin>>left[j]>>right[j]>>result[j];
		for (j=0;j<3;j++){
			if(result[j][0]=='u')
				for (i=0;i<strlen(left[j]);i++)
				{
					if (let[int(left[j][i]-'A')]!=10)
						let[int (left[j][i]-'A')]--;
					if (let[int (right[j][i]-'A')]!=10)
						let[int (right[j][i]-'A')]++;
				}
			if (result[j][0]=='d')
				for (i=0;i<strlen(left[j]);i++)
				{
					if (let[int(left[j][i]-'A')]!=10)
						let[int (left[j][i]-'A')]++;
					if (let[int (right[j][i]-'A')]!=10)
						let[int (right[j][i]-'A')]--;
				}
			if (result[j][0]=='e')
				for (i=0;i<strlen(left[j]);i++)
				{
					let[int (left[j][i]-'A')]=10;
					let[int (right[j][i]-'A')]=10;
				}
		}
		for (i=0;i<12;i++)
			if (p<fabs(let[i])&&let[i]!=10)
			{	p=fabs(let[i]);
				coin=i;
			}
		if (let[coin]>0)
			cout<<(char (coin+'A'))<<" is the counterfeit coin and it is light."<<endl;
		if (let[coin]<0)
			cout<<(char (coin+'A'))<<" is the counterfeit coin and it is heavy."<<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