2.1.1 Speed Limit

#include <iostream>
using namespace std;
int main()
{
	int n,i,x,y,z,ans;
	while(cin>>n&&n>0)
	{
		ans=z=0;
		for(i=0;i<n;i++)
		{
			cin>>x>>y;
			ans+=(y-z)*x;
			z=y;
		}
		cout<<ans<<" miles"<<endl;
	}
	return 0;
}

posted @ 2017-05-09 17:42  衣带渐宽、为伊憔悴  阅读(145)  评论(0编辑  收藏  举报