QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580317 | #9381. 502 Bad Gateway | syhyyds# | TL | 13ms | 10628kb | Python3 | 521b | 2024-09-21 21:04:42 | 2024-09-21 21:04:43 |
Judging History
answer
def gcd(x, y):
if x == 0: return y
if y == 0: return x
return gcd(x, y%x) if x < y else gcd(y, x%y)
def sum(n):
return n*(n+1)//2
T=int(input())
while T:
n=int(input())
sm=int(sum(n))
if(n*n-n<=sm):
d=gcd(sm,n)
sm//=d
n//=d
print(sm,n)
else:
x=int(sm//n+1)
ans=int(n*sum(x))
ans+=(sm+n)*(n-x)
n=n*n
d=int(gcd(ans,n))
ans=ans//d
n=n//d
print(ans,n)
T = T - 1
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 13ms
memory: 10628kb
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 750000001999999999 2000000000 1 1 1 1 750000001999999999 2000000000 1 1 750000001999999999 2000000000 1 1 1 1 1 1 750000001999999999 2000000000 1 1 1 1 750000001999999999 2000000000 1 1 750000001999999999 2000000000 750000001999999999 2000000000 1 1 750000001999999999 2000000000 1 1 1 1 75000000...