Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
注意!最后一个0之后可能是木有换行的,判断换行来确定终止会TLE#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator