QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#551356 | #9255. Python Program | ucup-team3734# | RE | 477ms | 10680kb | Python3 | 764b | 2024-09-07 16:34:53 | 2024-09-07 16:34:55 |
Judging History
answer
_ = input()
l1 = input()
l2 = input()
def find_range(s):
var = None
s = s.split(' ')
for i, x in enumerate(s):
if x == 'for':
var = s[i + 1]
for x in s:
if 'range(' in x:
return var, x.strip(':')
assert False
def parse_range(s):
s = s[5:].strip('()')
return s.split(',')
v, r1 = find_range(l1)
r1 = eval(r1)
_, r2 = find_range(l2)
a, b, c = parse_range(r2)
ia = int(a) if a != v else 0
ib = int(b) if b != v else 0
c = int(c)
ans = 0
for x in r1:
start = x if a == v else ia
end = x if b == v else ib
r = range(start, end, c)
l = len(r)
if l == 0:
continue
last = r[-1]
ans += (start + last) * l // 2
print(ans)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 10560kb
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: 14ms
memory: 10644kb
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: 477ms
memory: 10680kb
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: -100
Dangerous Syscalls
input:
ans=0 for i in range(31,321983,2): for j in range(313,382193): ans+=j print(ans)