oj1175: 我们都是好孩子

题目要求
有一次,小明在过马路的时候,发现马路中央有位老奶奶正好也在过马路。这时候小明想起妈妈经常教导的,于是赶紧追了过去。
注:小明开始位置在马路边。
Input
输入为多组,每组包含四个int范围内的非负整数,l、d、v1、v2( l>=d , v1>=v2>0)分别代表马路总长、老奶奶距离小明的距离、小明每秒走的距离、老奶奶每秒走的距离。当老奶奶和小明走在一起的时候,速度即为老奶奶的速度。
Output
对于每组输入,输出一个整数表示老奶奶和小明全部过了马路的时间,保证答案为整数。
Sample Input
Raw
8 4 2 1
36 18 9 2
Sample Output
Raw
4
9
将老人,小明走完所需时间相对比,取两个时间中的最大值。

#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;	
}
发布了38 篇原创文章 · 获赞 27 · 访问量 3186

猜你喜欢

转载自blog.csdn.net/qq_45891413/article/details/104887965