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

注意!最后一个0之后可能是木有换行的,判断换行来确定终止会TLE

Posted by KatrineYang at 2016-11-01 10:13:21 on Problem 1493 and last updated at 2016-11-01 10:51:03
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;

char mach[100][100];

int main() {
	while(1){
		char tmp;
		int n = 0;
		while(1){
			tmp = getchar();
			if(tmp < '0' || tmp > '9') break;//这里改成if(tmp == '\n')就会TLE
			n *= 10;
			n += (tmp - '0');
		}
		if(!n) break;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 25; j++){
				mach[i][j] = getchar();
			}
			tmp = getchar();
		}
		int numOfX[100] = {0}, mx = 0;
		for(int i = 0; i < n; i++){
			int temp = 0;
			for(int j = 0; j < 25; j++){
				if(mach[i][j] == 'X') temp++;
			}
			numOfX[i] = temp;
			if(temp > mx) mx = temp;
		}
		int res = 0;
		for(int i = 0; i < n; i++){
			res += mx - numOfX[i];
		}
		printf("%d\n", res);
	}
	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