QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756398 | #9622. 有限小数 | proking# | TL | 126ms | 10788kb | Python3 | 693b | 2024-11-16 20:19:18 | 2024-11-16 20:19:18 |
Judging History
answer
#!/usr/bin/env python3
def gcd(x, y):
if y == 0:
return x
return gcd(y, x % y)
def calc(a, b, pw_10):
tmp_c = b * ((a * pw_10 + b - 1) // b) - pw_10 * a
tmp_d = pw_10 * b
g = gcd(tmp_c, tmp_d)
return (tmp_c // g, tmp_d // g)
def solve():
a, b = (int(num) for num in input().split())
c_mn = 10**100
d_mn = 10**100
for i in range(3000):
c, d = calc(a, b, 10**i)
if c < c_mn:
c_mn = c
d_mn = d
pass
pass
print(c_mn, d_mn)
pass
if __name__ == "__main__":
T = eval(input())
for i in range(T):
solve()
pass
pass
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 126ms
memory: 10788kb
input:
4 1 2 2 3 3 7 19 79
output:
0 1 1 3 1 14 3 316
result:
ok 4 case(s)
Test #2:
score: -100
Time Limit Exceeded
input:
10000 11 12 28 53 17 60 2 35 17 181 80 123 68 141 79 163 71 99 13 64 33 61 15 32 16 61 11 86 33 74 128 143 40 53 7 23 30 31 5 6 86 181 73 91 13 23 71 81 1 2 7 38 117 160 33 83 129 151 88 153 25 58 16 19 19 141 95 124 43 96 71 139 11 59 106 109 93 152 34 43 17 99 1 57 20 159 16 25 5 73 159 170 172 17...
output:
1 12 1 132500000000 1 60 1 350 1 11312500000000000000000000000 23 246000 1 2203125000 1 25468750000000000000000000000000000000000 7 2475 0 1 1 61000 0 1 1 30500000000 1 10750 1 18500 1 1117187500 1 331250 1 460000 1 31 1 6 1 14140625000000000000000000000 1 455000 1 115000000 1 1265625 0 1 1 11875000...