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

为什么WA,我理解错了么?

Posted by kikif at 2007-09-05 20:39:21 on Problem 1789
#include <iostream>
#include <fstream>
using namespace std;

void main(){
//	ifstream cin("data.txt");
	while(1){
		int n,i,j,k;
		cin>>n;
		if(n==0)break;
		char str[2100][10];
		for(i=0;i<n;i++){
			cin>>str[i];
		}
		int len=strlen(str[0]);
		char tmp[10];
		for(i=0;i<7;i++){
			int a[26];
			memset(a,0,sizeof(a));
			int maxc;
			char c;
			for(j=0;j<n;j++){
				a[str[j][i]-'a']++;
			}
			int max=-1;
			int chac;
			for(j=0;j<26;j++){
				if(a[j]>max){
					max=a[j];
					chac=j;
				}
			}
			tmp[i]=chac+'a';
		}
		tmp[7]='\0';
		int dis=0;
		for(i=0;i<n;i++){
			for(j=0;j<7;j++){
				if(str[i][j]!=tmp[j])dis++;
			}
		}
		cout<<"The highest possible quality is 1/"<<dis<<"."<<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