Task: | GCD and LCM |
Sender: | aalto2024m_002 |
Submission time: | 2024-11-25 17:24:57 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | WRONG ANSWER | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.00 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | WRONG ANSWER | 0.01 s | details |
#17 | WRONG ANSWER | 0.00 s | details |
#18 | WRONG ANSWER | 0.00 s | details |
#19 | WRONG ANSWER | 0.00 s | details |
#20 | WRONG ANSWER | 0.10 s | details |
#21 | WRONG ANSWER | 0.00 s | details |
#22 | WRONG ANSWER | 0.01 s | details |
#23 | WRONG ANSWER | 0.00 s | details |
#24 | WRONG ANSWER | 0.00 s | details |
#25 | WRONG ANSWER | 0.01 s | details |
#26 | WRONG ANSWER | 0.14 s | details |
#27 | WRONG ANSWER | 0.00 s | details |
#28 | WRONG ANSWER | 0.00 s | details |
#29 | WRONG ANSWER | 0.00 s | details |
#30 | WRONG ANSWER | 0.00 s | details |
#31 | WRONG ANSWER | 0.01 s | details |
#32 | WRONG ANSWER | 0.01 s | details |
#33 | WRONG ANSWER | 0.00 s | details |
#34 | WRONG ANSWER | 0.01 s | details |
#35 | WRONG ANSWER | 0.00 s | details |
#36 | WRONG ANSWER | 0.00 s | details |
#37 | WRONG ANSWER | 0.00 s | details |
#38 | WRONG ANSWER | 0.00 s | details |
#39 | WRONG ANSWER | 0.00 s | details |
#40 | WRONG ANSWER | 0.00 s | details |
#41 | WRONG ANSWER | 0.00 s | details |
#42 | WRONG ANSWER | 0.00 s | details |
#43 | TIME LIMIT EXCEEDED | -- | details |
#44 | TIME LIMIT EXCEEDED | -- | details |
#45 | TIME LIMIT EXCEEDED | -- | details |
#46 | TIME LIMIT EXCEEDED | -- | details |
#47 | WRONG ANSWER | 0.00 s | details |
#48 | WRONG ANSWER | 0.00 s | details |
#49 | WRONG ANSWER | 0.00 s | details |
#50 | WRONG ANSWER | 0.00 s | details |
#51 | WRONG ANSWER | 0.00 s | details |
#52 | WRONG ANSWER | 0.00 s | details |
#53 | WRONG ANSWER | 0.00 s | details |
#54 | WRONG ANSWER | 0.00 s | details |
#55 | WRONG ANSWER | 1.09 s | details |
#56 | WRONG ANSWER | 1.09 s | details |
#57 | TIME LIMIT EXCEEDED | -- | details |
#58 | TIME LIMIT EXCEEDED | -- | details |
#59 | TIME LIMIT EXCEEDED | -- | details |
#60 | WRONG ANSWER | 1.09 s | details |
Code
#include <iostream> #include <vector> #include <bits/stdc++.h> using namespace std; #define int long long int gcd(int a, int b) { int c; while (b != 0) { c = a % b; a = b; b = c; } return a; } int lcm(int a, int b, int g) { return (a * b) / g; } using namespace std; pair <int, int> subset_mul(const vector<int>& nums, int n, int ss){ pair<int, int> t; t.first = 1; t.second = 1; if (n == 0){ return t; } vector<int> s = {0}; int d = ss - nums[0]; int r = nums[0]; for (int i = 0; i <n; i++) { const int v = s.size(); for (int t = 0; t < v; t++) { int k = s[t] * nums[i]; if (d >= abs(ss - k)) { d = abs(ss - k); r = k; } s.push_back(k); } } t.first = r; t.second = s[size(s) - 1]; return t; } vector<int> factors(int n) { vector<int> f; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { f.push_back(i); n /= i; while (n % i == 0) { f[size(f) - 1] *= i; n /= i; } } } return f; } signed main() { int a, b, g, l, h; cin >> a >> b; g = gcd(a, b); l = lcm(a, b, g); h = l / g; vector<int> f = factors(h); pair<int, int> t = subset_mul(f, size(f), sqrt(h)); int x, y; x = g * t.first; y = g * (t.second / t.first); cout << min(x, y) << " " << max(x, y) << endl; return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
3 4 |
correct output |
---|
3 4 |
user output |
---|
0 4 |
Test 2
Verdict: WRONG ANSWER
input |
---|
1 12 |
correct output |
---|
3 4 |
user output |
---|
0 4 |
Test 3
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
1 1 |
user output |
---|
1 1 |
Test 4
Verdict: WRONG ANSWER
input |
---|
1 2 |
correct output |
---|
1 2 |
user output |
---|
1 1 |
Test 5
Verdict: ACCEPTED
input |
---|
2 2 |
correct output |
---|
2 2 |
user output |
---|
2 2 |
Test 6
Verdict: WRONG ANSWER
input |
---|
2 1 |
correct output |
---|
1 2 |
user output |
---|
1 1 |
Test 7
Verdict: WRONG ANSWER
input |
---|
1 6 |
correct output |
---|
2 3 |
user output |
---|
0 2 |
Test 8
Verdict: WRONG ANSWER
input |
---|
1 9 |
correct output |
---|
1 9 |
user output |
---|
0 9 |
Test 9
Verdict: WRONG ANSWER
input |
---|
6 1 |
correct output |
---|
2 3 |
user output |
---|
0 2 |
Test 10
Verdict: WRONG ANSWER
input |
---|
1 1000000000 |
correct output |
---|
512 1953125 |
user output |
---|
0 512 |
Test 11
Verdict: WRONG ANSWER
input |
---|
4 48 |
correct output |
---|
12 16 |
user output |
---|
0 16 |
Test 12
Verdict: WRONG ANSWER
input |
---|
2 9 |
correct output |
---|
2 9 |
user output |
---|
0 2 |
Test 13
Verdict: WRONG ANSWER
input |
---|
9 2 |
correct output |
---|
2 9 |
user output |
---|
0 2 |
Test 14
Verdict: WRONG ANSWER
input |
---|
742625819 979252649 |
correct output |
---|
748840261 971126071 |
user output |
---|
0 3107221 |
Test 15
Verdict: WRONG ANSWER
input |
---|
742625819 628365177 |
correct output |
---|
628375693 742613391 |
user output |
---|
0 2151 |
Test 16
Verdict: WRONG ANSWER
input |
---|
59737016 594356392 |
correct output |
---|
84908056 418159112 |
user output |
---|
0 56 |
Test 17
Verdict: WRONG ANSWER
input |
---|
627952539 395203065 |
correct output |
---|
395203065 627952539 |
user output |
---|
0 15 |
Test 18
Verdict: WRONG ANSWER
input |
---|
454674271 444313814 |
correct output |
---|
444313814 454674271 |
user output |
---|
0 2 |
Test 19
Verdict: WRONG ANSWER
input |
---|
547252636 317707623 |
correct output |
---|
329474572 527707899 |
user output |
---|
0 4 |
Test 20
Verdict: WRONG ANSWER
input |
---|
848011418 576586631 |
correct output |
---|
576586631 848011418 |
user output |
---|
0 2 |
Test 21
Verdict: WRONG ANSWER
input |
---|
348776064 196069730 |
correct output |
---|
249125760 274497622 |
user output |
---|
0 128 |
Test 22
Verdict: WRONG ANSWER
input |
---|
237025447 149858613 |
correct output |
---|
149858613 237025447 |
user output |
---|
0 27 |
Test 23
Verdict: WRONG ANSWER
input |
---|
726392299 531452772 |
correct output |
---|
531452772 726392299 |
user output |
---|
0 4 |
Test 24
Verdict: WRONG ANSWER
input |
---|
59151261 839703616 |
correct output |
---|
186553977 266247488 |
user output |
---|
0 64 |
Test 25
Verdict: WRONG ANSWER
input |
---|
291928593 552857636 |
correct output |
---|
389238124 414643227 |
user output |
---|
0 4 |
Test 26
Verdict: WRONG ANSWER
input |
---|
421465106 509937555 |
correct output |
---|
421465106 509937555 |
user output |
---|
0 2 |
Test 27
Verdict: WRONG ANSWER
input |
---|
902518094 821875115 |
correct output |
---|
821875115 902518094 |
user output |
---|
0 2 |
Test 28
Verdict: WRONG ANSWER
input |
---|
301536505 988636664 |
correct output |
---|
482458408 617897915 |
user output |
---|
0 8 |
Test 29
Verdict: WRONG ANSWER
input |
---|
802229414 316587683 |
correct output |
---|
479117567 530091086 |
user output |
---|
0 2 |
Test 30
Verdict: WRONG ANSWER
input |
---|
326192670 575151518 |
correct output |
---|
326192670 575151518 |
user output |
---|
0 162 |
Test 31
Verdict: WRONG ANSWER
input |
---|
548703061 432915082 |
correct output |
---|
432915082 548703061 |
user output |
---|
0 2 |
Test 32
Verdict: WRONG ANSWER
input |
---|
969217649 547557803 |
correct output |
---|
547557803 969217649 |
user output |
---|
0 169 |
Test 33
Verdict: WRONG ANSWER
input |
---|
33451382 190448754 |
correct output |
---|
63482918 100354146 |
user output |
---|
0 6 |
Test 34
Verdict: WRONG ANSWER
input |
---|
910804372 355985662 |
correct output |
---|
455402186 711971324 |
user output |
---|
0 4 |
Test 35
Verdict: WRONG ANSWER
input |
---|
557993572 616540429 |
correct output |
---|
557993572 616540429 |
user output |
---|
0 4 |
Test 36
Verdict: WRONG ANSWER
input |
---|
999999999 1000000000 |
correct output |
---|
999999999 1000000000 |
user output |
---|
0 512 |
Test 37
Verdict: WRONG ANSWER
input |
---|
999999761 1000000000 |
correct output |
---|
999999761 1000000000 |
user output |
---|
0 512 |
Test 38
Verdict: WRONG ANSWER
input |
---|
1 1000000000 |
correct output |
---|
512 1953125 |
user output |
---|
0 512 |
Test 39
Verdict: WRONG ANSWER
input |
---|
500000000 1000000000 |
correct output |
---|
500000000 1000000000 |
user output |
---|
500000000 500000000 |
Test 40
Verdict: WRONG ANSWER
input |
---|
200000000 1000000000 |
correct output |
---|
200000000 1000000000 |
user output |
---|
200000000 200000000 |
Test 41
Verdict: WRONG ANSWER
input |
---|
971959530 977699359 |
correct output |
---|
973924458 975726815 |
user output |
---|
0 34 |
Test 42
Verdict: WRONG ANSWER
input |
---|
991437195 958491586 |
correct output |
---|
973924458 975726815 |
user output |
---|
0 34 |
Test 43
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999937 999999929 |
correct output |
---|
999999929 999999937 |
user output |
---|
(empty) |
Test 44
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999751 999999757 |
correct output |
---|
999999751 999999757 |
user output |
---|
(empty) |
Test 45
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999739 999999599 |
correct output |
---|
999999599 999999739 |
user output |
---|
(empty) |
Test 46
Verdict: TIME LIMIT EXCEEDED
input |
---|
999997357 999997403 |
correct output |
---|
999997357 999997403 |
user output |
---|
(empty) |
Test 47
Verdict: WRONG ANSWER
input |
---|
999999937 2 |
correct output |
---|
2 999999937 |
user output |
---|
0 2 |
Test 48
Verdict: WRONG ANSWER
input |
---|
999999937 5 |
correct output |
---|
5 999999937 |
user output |
---|
0 5 |
Test 49
Verdict: WRONG ANSWER
input |
---|
999999986 2 |
correct output |
---|
2 999999986 |
user output |
---|
2 2 |
Test 50
Verdict: WRONG ANSWER
input |
---|
999999986 3 |
correct output |
---|
6 499999993 |
user output |
---|
0 2 |
Test 51
Verdict: WRONG ANSWER
input |
---|
999999979 2 |
correct output |
---|
22 90909089 |
user output |
---|
0 2 |
Test 52
Verdict: WRONG ANSWER
input |
---|
818181801 3 |
correct output |
---|
9 272727267 |
user output |
---|
0 9 |
Test 53
Verdict: WRONG ANSWER
input |
---|
636363623 5 |
correct output |
---|
35 90909089 |
user output |
---|
0 5 |
Test 54
Verdict: WRONG ANSWER
input |
---|
909090890 12 |
correct output |
---|
60 181818178 |
user output |
---|
0 4 |
Test 55
Verdict: WRONG ANSWER
input |
---|
999999979 999999986 |
correct output |
---|
999999979 999999986 |
user output |
---|
0 2 |
Test 56
Verdict: WRONG ANSWER
input |
---|
999999979 999999937 |
correct output |
---|
999999937 999999979 |
user output |
---|
0 11 |
Test 57
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999986 999999929 |
correct output |
---|
999999929 999999986 |
user output |
---|
(empty) |
Test 58
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999986 999999757 |
correct output |
---|
999999757 999999986 |
user output |
---|
(empty) |
Test 59
Verdict: TIME LIMIT EXCEEDED
input |
---|
999999939 999999929 |
correct output |
---|
999999929 999999939 |
user output |
---|
(empty) |
Test 60
Verdict: WRONG ANSWER
input |
---|
636363623 999999929 |
correct output |
---|
636363623 999999929 |
user output |
---|
0 7 |