oj1175: we were good

Subject requirements
Once, Xiao Ming in crossing the street, found middle of the road there was a grandmother is also just across the street. This time Xiao Ming think of my mother often taught, then quickly recover the past.
Note: Xiao Ming in the starting position side of the road.
Input
input a plurality of groups, each group comprising a non-negative integer in the range of four int, l, d, v1, v2 (l> = d, v1> = v2> 0) represent the total length of the road, the distance from the grandmother Xiaoming, Xiao Ming to go the distance per second, per second grandmother walking distance. When the grandmother and Xiao Ming go together, speed is the grandmother of speed.
Output
For each input, and outputs an integer grandmother Xiaoming Guoliaomalu all the time to ensure that the answer is an integer.
The Input the Sample
Raw
. 8. 1. 4 2
36 2. 9 18 is
the Sample the Output
Raw
. 4
. 9
for the elderly, the time required to finish Xiaoming contrast, take the maximum of two times.

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
	int l, d, v1, v2;
	while (cin >> l >> d >> v1 >> v2)
	{
		int t = 0;
		int t1,t2;
		t1 = (l - d) / v2;
		t2 = l / v1;
		if (t2 > t1)
			t = t1 + (t2 - t1);
		else
			t = t1;
		cout << t << endl;
	}
	return 0;	
}
Published 38 original articles · won praise 27 · views 3186

Guess you like

Origin blog.csdn.net/qq_45891413/article/details/104887965