QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#636685 | #9255. Python Program | maspy | AC ✓ | 980ms | 10660kb | Python3 | 560b | 2024-10-13 01:52:51 | 2024-10-13 01:52:51 |
Judging History
answer
txt = [input() for _ in range(5)]
def find(X):
p=X.find("range")
X=X[p+5:][1:-2]
X=X.split(",")
if len(X)==2:
X.append("1")
return X
A=find(txt[1])
B=find(txt[2])
ANS = 0
a,b,c=map(int,A)
x=0
def f(s):
if s.lstrip('-').isdigit():
return int(s)
return x
for x in range(a,b,c):
p,q,r=map(f,B)
if r > 0:
k = max(0, (q-1-p)//r+1)
ANS += (2*p+r*k-r)*k
else:
r = -r
k = max(0,(p-q-1)//r+1)
ANS += (2*p-r*k+r)*k
ANS//=2
print(ANS)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 10656kb
input:
ans=0 for a in range(1,3): for b in range(5,1,-2): ans+=b print(ans)
output:
16
result:
ok single line: '16'
Test #2:
score: 0
Accepted
time: 8ms
memory: 10548kb
input:
ans=0 for q in range(100,50,-1): for i in range(q,77,20): ans+=i print(ans)
output:
2092
result:
ok single line: '2092'
Test #3:
score: 0
Accepted
time: 969ms
memory: 10660kb
input:
ans=0 for i in range(1,1000000): for j in range(i,1,-1): ans+=j print(ans)
output:
166666666665500001
result:
ok single line: '166666666665500001'
Test #4:
score: 0
Accepted
time: 176ms
memory: 10588kb
input:
ans=0 for i in range(31,321983,2): for j in range(313,382193): ans+=j print(ans)
output:
11756963404587200
result:
ok single line: '11756963404587200'
Test #5:
score: 0
Accepted
time: 980ms
memory: 10624kb
input:
ans=0 for i in range(1,1000000): for j in range(i,114514,-1): ans+=j print(ans)
output:
160610445975856765
result:
ok single line: '160610445975856765'
Extra Test:
score: 0
Extra Test Passed