Skip to content

Commit dfa5912

Browse files
Create Divisible Numbers Easy Version.cpp
1 parent 9686a02 commit dfa5912

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <algorithm>
4+
#include <map>
5+
6+
using namespace std;
7+
8+
void solve()
9+
{
10+
long long a, b, c, d;
11+
cin >> a >> b >> c >> d;
12+
13+
long long answer_x = -1, answer_y = -1;
14+
for(long long x = a + 1; x <= c; x++)
15+
{
16+
long long complement = (a*b)/__gcd(a*b, x);
17+
//cout << "X = " << x << " Complement = " << complement << "\n";
18+
19+
long long y = complement;
20+
21+
for(int i = 1; y <= b; i++)
22+
{
23+
y = i*complement;
24+
}
25+
//cout << "Y = " << y << "\n";
26+
if(y <= d)
27+
{
28+
answer_x = x, answer_y = y;
29+
break;
30+
}
31+
}
32+
33+
cout << answer_x << " " << answer_y << "\n";
34+
}
35+
36+
int main()
37+
{
38+
int no_of_test_cases;
39+
cin >> no_of_test_cases;
40+
41+
while(no_of_test_cases--)
42+
solve();
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)