Task: | GCD and LCM |
Sender: | aalto2024m_002 |
Submission time: | 2024-11-25 16:55:36 +0200 |
Language: | Python3 (PyPy3) |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | RUNTIME ERROR | 0.06 s | details |
#4 | ACCEPTED | 0.04 s | details |
#5 | RUNTIME ERROR | 0.06 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | ACCEPTED | 0.04 s | details |
#8 | ACCEPTED | 0.04 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.04 s | details |
#11 | ACCEPTED | 0.04 s | details |
#12 | ACCEPTED | 0.04 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | ACCEPTED | 0.04 s | details |
#15 | ACCEPTED | 0.05 s | details |
#16 | ACCEPTED | 0.05 s | details |
#17 | ACCEPTED | 0.04 s | details |
#18 | ACCEPTED | 0.04 s | details |
#19 | ACCEPTED | 0.04 s | details |
#20 | ACCEPTED | 0.17 s | details |
#21 | ACCEPTED | 0.05 s | details |
#22 | ACCEPTED | 0.04 s | details |
#23 | ACCEPTED | 0.05 s | details |
#24 | ACCEPTED | 0.04 s | details |
#25 | ACCEPTED | 0.04 s | details |
#26 | ACCEPTED | 0.22 s | details |
#27 | ACCEPTED | 0.05 s | details |
#28 | ACCEPTED | 0.04 s | details |
#29 | ACCEPTED | 0.05 s | details |
#30 | ACCEPTED | 0.04 s | details |
#31 | ACCEPTED | 0.06 s | details |
#32 | ACCEPTED | 0.05 s | details |
#33 | ACCEPTED | 0.04 s | details |
#34 | ACCEPTED | 0.05 s | details |
#35 | ACCEPTED | 0.05 s | details |
#36 | ACCEPTED | 0.04 s | details |
#37 | ACCEPTED | 0.04 s | details |
#38 | ACCEPTED | 0.04 s | details |
#39 | ACCEPTED | 0.04 s | details |
#40 | ACCEPTED | 0.04 s | details |
#41 | ACCEPTED | 0.06 s | details |
#42 | ACCEPTED | 0.05 s | details |
#43 | TIME LIMIT EXCEEDED | -- | details |
#44 | TIME LIMIT EXCEEDED | -- | details |
#45 | TIME LIMIT EXCEEDED | -- | details |
#46 | TIME LIMIT EXCEEDED | -- | details |
#47 | ACCEPTED | 0.04 s | details |
#48 | ACCEPTED | 0.04 s | details |
#49 | ACCEPTED | 0.04 s | details |
#50 | ACCEPTED | 0.05 s | details |
#51 | ACCEPTED | 0.04 s | details |
#52 | ACCEPTED | 0.05 s | details |
#53 | ACCEPTED | 0.04 s | details |
#54 | ACCEPTED | 0.04 s | details |
#55 | ACCEPTED | 1.48 s | details |
#56 | ACCEPTED | 1.48 s | details |
#57 | TIME LIMIT EXCEEDED | -- | details |
#58 | TIME LIMIT EXCEEDED | -- | details |
#59 | TIME LIMIT EXCEEDED | -- | details |
#60 | ACCEPTED | 1.49 s | details |
Code
import sys import math sys.setrecursionlimit(10**6) def gcd(a, b): while b != 0: a, b = b, a%b return a def lcm(a, b, g): return (a * b) // g def subset_mul(x, n, s): total = 1 << n d = s - x[0] r = x[0] fn = 1 for i in range(total): m = 1 for j in range(n): if (i & (1 << j)) != 0: m *= x[j] if d >= abs(s - m): d = abs(s - m) r = m fn = m return r, m def factors(n): f = [] i = 2 while i * i <= n: if n % i == 0: f.append(i) n //= i while n % i == 0: n //= i f[-1] *= i i += 1 if n != 1: f.append(n) return f a, b = map(int, input().split()) g = gcd(a, b) l = lcm(a, b, g) h = l // g f = factors(h) r, fn = subset_mul(f, len(f), int(h ** 0.5)) # print(g, l, f, r, fn) # print(r, g * r) x, y = g * r, g * (fn // r) print(min(x, y), max(x, y))
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3 4 |
correct output |
---|
3 4 |
user output |
---|
3 4 |
Test 2
Verdict: ACCEPTED
input |
---|
1 12 |
correct output |
---|
3 4 |
user output |
---|
3 4 |
Test 3
Verdict: RUNTIME ERROR
input |
---|
1 1 |
correct output |
---|
1 1 |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 53, in <module> r, fn...
Test 4
Verdict: ACCEPTED
input |
---|
1 2 |
correct output |
---|
1 2 |
user output |
---|
1 2 |
Test 5
Verdict: RUNTIME ERROR
input |
---|
2 2 |
correct output |
---|
2 2 |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 53, in <module> r, fn...
Test 6
Verdict: ACCEPTED
input |
---|
2 1 |
correct output |
---|
1 2 |
user output |
---|
1 2 |
Test 7
Verdict: ACCEPTED
input |
---|
1 6 |
correct output |
---|
2 3 |
user output |
---|
2 3 |
Test 8
Verdict: ACCEPTED
input |
---|
1 9 |
correct output |
---|
1 9 |
user output |
---|
1 9 |
Test 9
Verdict: ACCEPTED
input |
---|
6 1 |
correct output |
---|
2 3 |
user output |
---|
2 3 |
Test 10
Verdict: ACCEPTED
input |
---|
1 1000000000 |
correct output |
---|
512 1953125 |
user output |
---|
512 1953125 |
Test 11
Verdict: ACCEPTED
input |
---|
4 48 |
correct output |
---|
12 16 |
user output |
---|
12 16 |
Test 12
Verdict: ACCEPTED
input |
---|
2 9 |
correct output |
---|
2 9 |
user output |
---|
2 9 |
Test 13
Verdict: ACCEPTED
input |
---|
9 2 |
correct output |
---|
2 9 |
user output |
---|
2 9 |
Test 14
Verdict: ACCEPTED
input |
---|
742625819 979252649 |
correct output |
---|
748840261 971126071 |
user output |
---|
748840261 971126071 |
Test 15
Verdict: ACCEPTED
input |
---|
742625819 628365177 |
correct output |
---|
628375693 742613391 |
user output |
---|
628375693 742613391 |
Test 16
Verdict: ACCEPTED
input |
---|
59737016 594356392 |
correct output |
---|
84908056 418159112 |
user output |
---|
84908056 418159112 |
Test 17
Verdict: ACCEPTED
input |
---|
627952539 395203065 |
correct output |
---|
395203065 627952539 |
user output |
---|
395203065 627952539 |
Test 18
Verdict: ACCEPTED
input |
---|
454674271 444313814 |
correct output |
---|
444313814 454674271 |
user output |
---|
444313814 454674271 |
Test 19
Verdict: ACCEPTED
input |
---|
547252636 317707623 |
correct output |
---|
329474572 527707899 |
user output |
---|
329474572 527707899 |
Test 20
Verdict: ACCEPTED
input |
---|
848011418 576586631 |
correct output |
---|
576586631 848011418 |
user output |
---|
576586631 848011418 |
Test 21
Verdict: ACCEPTED
input |
---|
348776064 196069730 |
correct output |
---|
249125760 274497622 |
user output |
---|
249125760 274497622 |
Test 22
Verdict: ACCEPTED
input |
---|
237025447 149858613 |
correct output |
---|
149858613 237025447 |
user output |
---|
149858613 237025447 |
Test 23
Verdict: ACCEPTED
input |
---|
726392299 531452772 |
correct output |
---|
531452772 726392299 |
user output |
---|
531452772 726392299 |
Test 24
Verdict: ACCEPTED
input |
---|
59151261 839703616 |
correct output |
---|
186553977 266247488 |
user output |
---|
186553977 266247488 |
Test 25
Verdict: ACCEPTED
input |
---|
291928593 552857636 |
correct output |
---|
389238124 414643227 |
user output |
---|
389238124 414643227 |
Test 26
Verdict: ACCEPTED
input |
---|
421465106 509937555 |
correct output |
---|
421465106 509937555 |
user output |
---|
421465106 509937555 |
Test 27
Verdict: ACCEPTED
input |
---|
902518094 821875115 |
correct output |
---|
821875115 902518094 |
user output |
---|
821875115 902518094 |
Test 28
Verdict: ACCEPTED
input |
---|
301536505 988636664 |
correct output |
---|
482458408 617897915 |
user output |
---|
482458408 617897915 |
Test 29
Verdict: ACCEPTED
input |
---|
802229414 316587683 |
correct output |
---|
479117567 530091086 |
user output |
---|
479117567 530091086 |
Test 30
Verdict: ACCEPTED
input |
---|
326192670 575151518 |
correct output |
---|
326192670 575151518 |
user output |
---|
326192670 575151518 |
Test 31
Verdict: ACCEPTED
input |
---|
548703061 432915082 |
correct output |
---|
432915082 548703061 |
user output |
---|
432915082 548703061 |
Test 32
Verdict: ACCEPTED
input |
---|
969217649 547557803 |
correct output |
---|
547557803 969217649 |
user output |
---|
547557803 969217649 |
Test 33
Verdict: ACCEPTED
input |
---|
33451382 190448754 |
correct output |
---|
63482918 100354146 |
user output |
---|
63482918 100354146 |
Test 34
Verdict: ACCEPTED
input |
---|
910804372 355985662 |
correct output |
---|
455402186 711971324 |
user output |
---|
455402186 711971324 |
Test 35
Verdict: ACCEPTED
input |
---|
557993572 616540429 |
correct output |
---|
557993572 616540429 |
user output |
---|
557993572 616540429 |
Test 36
Verdict: ACCEPTED
input |
---|
999999999 1000000000 |
correct output |
---|
999999999 1000000000 |
user output |
---|
999999999 1000000000 |
Test 37
Verdict: ACCEPTED
input |
---|
999999761 1000000000 |
correct output |
---|
999999761 1000000000 |
user output |
---|
999999761 1000000000 |
Test 38
Verdict: ACCEPTED
input |
---|
1 1000000000 |
correct output |
---|
512 1953125 |
user output |
---|
512 1953125 |
Test 39
Verdict: ACCEPTED
input |
---|
500000000 1000000000 |
correct output |
---|
500000000 1000000000 |
user output |
---|
500000000 1000000000 |
Test 40
Verdict: ACCEPTED
input |
---|
200000000 1000000000 |
correct output |
---|
200000000 1000000000 |
user output |
---|
200000000 1000000000 |
Test 41
Verdict: ACCEPTED
input |
---|
971959530 977699359 |
correct output |
---|
973924458 975726815 |
user output |
---|
973924458 975726815 |
Test 42
Verdict: ACCEPTED
input |
---|
991437195 958491586 |
correct output |
---|
973924458 975726815 |
user output |
---|
973924458 975726815 |
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: ACCEPTED
input |
---|
999999937 2 |
correct output |
---|
2 999999937 |
user output |
---|
2 999999937 |
Test 48
Verdict: ACCEPTED
input |
---|
999999937 5 |
correct output |
---|
5 999999937 |
user output |
---|
5 999999937 |
Test 49
Verdict: ACCEPTED
input |
---|
999999986 2 |
correct output |
---|
2 999999986 |
user output |
---|
2 999999986 |
Test 50
Verdict: ACCEPTED
input |
---|
999999986 3 |
correct output |
---|
6 499999993 |
user output |
---|
6 499999993 |
Test 51
Verdict: ACCEPTED
input |
---|
999999979 2 |
correct output |
---|
22 90909089 |
user output |
---|
22 90909089 |
Test 52
Verdict: ACCEPTED
input |
---|
818181801 3 |
correct output |
---|
9 272727267 |
user output |
---|
9 272727267 |
Test 53
Verdict: ACCEPTED
input |
---|
636363623 5 |
correct output |
---|
35 90909089 |
user output |
---|
35 90909089 |
Test 54
Verdict: ACCEPTED
input |
---|
909090890 12 |
correct output |
---|
60 181818178 |
user output |
---|
60 181818178 |
Test 55
Verdict: ACCEPTED
input |
---|
999999979 999999986 |
correct output |
---|
999999979 999999986 |
user output |
---|
999999979 999999986 |
Test 56
Verdict: ACCEPTED
input |
---|
999999979 999999937 |
correct output |
---|
999999937 999999979 |
user output |
---|
999999937 999999979 |
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: ACCEPTED
input |
---|
636363623 999999929 |
correct output |
---|
636363623 999999929 |
user output |
---|
636363623 999999929 |