QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671763#9381. 502 Bad Gatewaywjh111TL 10ms10820kbPython3396b2024-10-24 14:22:062024-10-24 14:22:06

Judging History

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

  • [2024-10-24 14:22:06]
  • 评测
  • 测评结果:TL
  • 用时:10ms
  • 内存:10820kb
  • [2024-10-24 14:22:06]
  • 提交

answer

import math as m
t=int(input())
for i in range(t):
    n=int(input())
    w=int(m.sqrt(2*n))
    w1=w+1
    u=w*w-w+2*n
    k=2*w
    p=m.gcd(u,k)
    u=u//p
    k=k//p
    if ((w*w)==(2*n)):
        print(u,k)
        continue
    u1=w1*w1-w1+2*n
    k1=2*w1
    p=m.gcd(u1,k1)
    u1=u1//p
    k1=k1//p
    if (u*k1>u1*k):
        print(u,k)
    else:
        print(u1,k1)

詳細信息

Test #1:

score: 100
Accepted
time: 10ms
memory: 10820kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Time Limit Exceeded

input:

1000000
1
1000000000
1
1
1000000000
1
1000000000
1
1
1
1000000000
1
1
1000000000
1
1000000000
1000000000
1
1000000000
1
1
1000000000
1
1000000000
1000000000
1
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1
1
1000000000
1
1000000000
1000000000
1000000000
1000000000
1
1
1
10000000...

output:

1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
1 1
1 1
1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
2000006281 44722
1 1
2000006281 44722
1 1
1 1
2000006281 44722
1 1
2000006281 44722
2000006281 44722
1 1
2000006281 44722
2000006281 44722
2000006281 44722
20...

result: