QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580263 | #9381. 502 Bad Gateway | syhyyds | RE | 0ms | 0kb | Python3 | 505b | 2024-09-21 20:48:43 | 2024-09-21 20:48:44 |
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)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
3 1 2 3
output:
1 1 3 2 2 1