Home > Back-end >  On a simple decision problem, consult everybody bosses
On a simple decision problem, consult everybody bosses

Time:10-03

Only if the following two paragraphs source difference between the else part of the former on the oj can't all through, the latter can, thinking for a long time to make impassability, please bosses kangkang
 # include & lt; Iostream> 
# include & lt; Iomanip>
# include & lt; Cmath>
using namespace std;
Int main () {
Int n, v1, v2, t;
Cin & gt;> n> V1 & gt;> V2 & gt;> t;
If (v1 * t & gt;=t + v2 * n& & T<{
=1000)Double final_t=(double) n/(v1, v2);
Cout & lt; }
The else cout & lt; <"1";
return 0;
}


 # include & lt; Iostream> 
# include & lt; Iomanip>
# include & lt; Cmath>
using namespace std;
Int main () {
Int n, v1, v2, t;
Cin & gt;> n> V1 & gt;> V2 & gt;> t;
Double final_t=1.0 * n/(v1, v2);

If (final_t & gt; T | | final_t & lt; 0 {
Cout & lt; <"1";
}
The else cout & lt; return 0;
}


Attached to the topic: there are two cars. A, b n meters apart, on the right side of the a, b and regulation, to the right as the positive direction, start from time zero, a, b, respectively in v1, v2 speed (m/s), ask at time t (s), the car can be met, if can meet, meet the output moment (unit s, round two decimal places after the decimal point), if not the output 1,
Input: a line, four integer, n, v1, v2, and t (0 & lt;=n, | v1, | | | v2, t
=1000)Output: a line, a number, if can meet, as long as there is a time of two cars from 0, even to meet), meet the output moment; If can't meet, output 1
  • Related