UVa 414 Machined Surface
睡個覺,突然就想通了。
15分鐘KO! 一次AC,KERKER!
15分鐘KO! 一次AC,KERKER!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* UVa 414 Machined Surface | |
* Author: chchwy | |
* Last Modified: 2010.02.06 | |
*/ | |
#include<iostream> | |
using namespace std; | |
int run (int numLine) | |
{ | |
int minSpace = 25; | |
int totalSpace = 0; | |
for (int i = 0; i < numLine; ++i) | |
{ | |
char buf[32]; | |
fgets(buf, sizeof(buf), stdin); | |
int curSpace = 0; | |
for (int i = 0; i < 25; ++i) | |
{ | |
if (buf[i] == ' ') | |
curSpace++; | |
} | |
if (curSpace < minSpace) | |
minSpace = curSpace; | |
totalSpace += curSpace; | |
} | |
return totalSpace - (minSpace * numLine); | |
} | |
int main() | |
{ | |
#ifndef ONLINE_JUDGE | |
freopen("414.in", "r", stdin); | |
#endif | |
int numLine; | |
while ( scanf("%d ", &numLine) ) | |
{ | |
if ( numLine == 0 ) break; | |
printf("%d\n", run(numLine) ); | |
} | |
return 0; | |
} |
留言
張貼留言