QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#552014 | #9255. Python Program | ucup-team3670# | TL | 17ms | 10712kb | Python3 | 574b | 2024-09-07 19:48:18 | 2024-09-07 19:48:19 |
Judging History
answer
def parse(s):
i = s.split()[1]
s = s.split('(')[-1]
s = s.split(')')[0]
s = s.split(',')
if len(s) == 2:
s.append('1')
return [i] + s
exec(input())
s = parse(input().strip())
t = parse(input().strip())
for it in range(int(s[1]), int(s[2]), int(s[3])):
exec(s[0] + '=' + str(it))
lf = eval(t[1])
rg = eval(t[2])
st = eval(t[3])
coef = 1
if st < 0:
lf = -lf
rg = -rg
st = -st
coef = -1
rg -= 1
if lf <= rg:
fst = lf
cnt = (rg - lf) // st
lst = fst + cnt * st
ans += coef * ((fst + lst) * (cnt + 1) // 2)
print(ans)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 10612kb
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: 17ms
memory: 10712kb
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: -100
Time Limit Exceeded
input:
ans=0 for i in range(1,1000000): for j in range(i,1,-1): ans+=j print(ans)