QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#551481 | #9255. Python Program | ucup-team4508# | AC ✓ | 806ms | 10708kb | Python3 | 758b | 2024-09-07 17:04:54 | 2024-09-07 17:04:55 |
Judging History
answer
lis = []
for i in range(5): lis.append(input())
a, b = lis[1: 3]
a=a.strip()
b=b.strip()
def calc(x,y,z):
sb=0
if z>0:
if x<y:
y-=1
cnt=(y-x)//z+1
sb=(x+x+z*(cnt-1))*cnt//2
else:
if x>y:
y+=1
cnt=(x-y)//(-z)+1
sb=(x+x+z*(cnt-1))*cnt//2
return sb
la = a[a.index('(')+1: a.index(')')]
lb = b[b.index('(')+1: b.index(')')]
la = la.split(',')
lb = lb.split(',')
ans=0
for i in range(*map(int,la)):
def dec(s):
if s==a[4]:
return i
else:
return int(s)
x=dec(lb[0])
y=dec(lb[1])
if len(lb)==2:
z=1
else:
z=dec(lb[2])
ans+=calc(x,y,z)
print(ans)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 10708kb
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: 0ms
memory: 10604kb
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: 806ms
memory: 10700kb
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: 145ms
memory: 10520kb
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: 798ms
memory: 10632kb
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