Skip to content

Commit 2b799a3

Browse files
Create Two Rabbits.cpp
1 parent 9bb3212 commit 2b799a3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
void solve()
6+
{
7+
long long position_1, position_2, distance_1, distance_2;
8+
cin >> position_1 >> position_2 >> distance_1 >> distance_2;
9+
10+
long long time = ((position_2 - position_1)%(distance_1 + distance_2) == 0 ? (position_2 - position_1)/(distance_1 + distance_2) : -1);
11+
cout << time << "\n";
12+
}
13+
14+
int main()
15+
{
16+
int no_of_test_cases;
17+
cin >> no_of_test_cases;
18+
19+
while(no_of_test_cases--)
20+
solve();
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)