1. 程式人生 > >jzxx1516題麻煩的乾草打包機

jzxx1516題麻煩的乾草打包機

#include<iostream>
#include<math.h>
using namespace std;
int i,j,c=10000,sum=0;
int x[100],y[100],r[100],d[100];
int main()
{
	int  n,x_t,y_t;
	cin>>n>>x_t>>y_t;
	cin>>x[0]>>y[0]>>r[0];
	d[0]=c;
	for(i=1; i<n; i++)
	{
		cin>>x[i]>>y[i]>>r[i];
		d[i]=-(d[i-1]*r[i-1]/r[i]);
		if(x[i]==x_t&&y[i]==y_t)
		{
			d[i]=-d[i-1]*r[i-1]/r[i];
			j=i;
			continue;
		}
	}
	for(i=0; i<=j; i++)
	{
		if(i%2==0)
			sum+=d[i];
		else
			sum-=d[i];
	}
	cout<<sum<<endl;
	return 0;
}