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

1AC感谢前辈们的disguss……

Posted by CUGB1004101218 at 2011-02-26 23:36:43 on Problem 1013
#include <iostream>
#include <cmath>
using namespace std;
char l[3][7],r[3][7],a[3][7];
int b[15];
int i,n,k,j,t;

int main()
{
	cin>>t;
	for(k=0;k<t;k++){
		memset(b,0,sizeof(b));
		for(i=0;i<3;i++)
			cin>>l[i]>>r[i]>>a[i];
		for(i=0;i<3;i++){
			n=strlen(l[i]);
			if(a[i][0]=='e')
				for(j=0;j<n;j++){
					b[l[i][j]-'A']=100;
					b[r[i][j]-'A']=100;
				}
		}
		for(i=0;i<3;i++){
			n=strlen(l[i]);
			for(j=0;j<n;j++){
				if(a[i][0]=='u'){
					if(b[l[i][j]-'A']!=100)
						b[l[i][j]-'A']++;
					if(b[r[i][j]-'A']!=100)
						b[r[i][j]-'A']--;
				}
				if(a[i][0]=='d'){
					if(b[r[i][j]-'A']!=100)
						b[r[i][j]-'A']++;
					if(b[l[i][j]-'A']!=100)
						b[l[i][j]-'A']--;
				}
			}
		}
		int m=0;
		int z=0;
		for(i=0;i<15;i++){
			if(b[i]==100)
				continue;
			if(abs(b[i])>m){
				m=abs(b[i]);
				z=i;
			}
		}
		if(b[z]>0)
			cout<<char('A'+z)<<" is the counterfeit coin and it is heavy."<<endl;
		else
			cout<<char('A'+z)<<" is the counterfeit coin and it is light."<<endl;
	}
	return 0;
}


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