QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737333#9622. 有限小数UESTC_NLNSCompile Error//C++20468b2024-11-12 15:31:142024-11-12 15:31:15

Judging History

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

  • [2024-11-12 15:31:15]
  • 评测
  • [2024-11-12 15:31:14]
  • 提交

answer

a=[2**i for i in range(40)]
b=[5**i for i in range(40)]
V=[i*j for i in a for j in b]
inf=1e9
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*=5
        b//=5
    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)

Details

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