QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736710#9622. 有限小数UESTC_NLNSCompile Error//C++20604b2024-11-12 12:48:232024-11-12 12:48:24

Judging History

你现在查看的是最新测评结果

  • [2024-11-12 12:48:24]
  • 评测
  • [2024-11-12 12:48:23]
  • 提交

answer

a = [2**i for i in range(40)]
b = [5**i for i in range(40)]
V = []
inf = 1e9
for i in a:
    for j in b:
        if i * j <= inf:
            V.append(i * j)

V.sort()
t = int(input())
for i in range(t):
    a, b = map(int, input().split())
    as1 = as2 = inf
    T = 1
    while b % 2 == 0:
        T *= 2
        b //= 2
    while b % 5 == 0:
        T *= 2
        b //= 2
    iT = pow(T, -1, b)
    for v in V:
        if b * v > inf:
            break
        d = b * v
        c = (-a * v * iT) % b
        if c < as1:
            as1, as2 = c, d
    print(as1, as2)

详细

answer.code:1:1: error: ‘a’ does not name a type
    1 | a = [2**i for i in range(40)]
      | ^