UVa 414 Machined Surface

睡個覺,突然就想通了。
15分鐘KO! 一次AC,KERKER!

/**
* 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;
}
view raw 414.cpp hosted with ❤ by GitHub

留言

這個網誌中的熱門文章

UVa 10125 Sumsets

讀書心得: 撒哈拉的故事

讀書心得: 你以為你以為的就是你以為的嗎?