现在的位置: 首页 > 综合 > 正文

414 – Machined Surfaces

2013年03月22日 ⁄ 综合 ⁄ 共 408字 ⁄ 字号 评论关闭

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=355

右边的往左边靠,当第一个接触后,求得离的最远的距离

#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	string c;
	int n;	
	while(cin >> n)
	{
		int sum=0;
		int sp=25;
		if(n==0)
			break;
		getchar();
		for(int i=0; i<n; i++)
		{
			cin >> c;
			int t = 0;
			int ch;
			while((ch=getchar())!='\n')
			{
				if(ch==' ')
				{
					t++;
					sum++;
				}					
			}
			if(t<sp)
				sp=t;
		}
		cout << sum - sp*n << endl;
		sum=0;
	}
	return 0;
}

抱歉!评论已关闭.