QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#551369 | #9255. Python Program | ucup-team3734# | RE | 0ms | 0kb | Python3 | 835b | 2024-09-07 16:37:13 | 2024-09-07 16:37:14 |
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)
x, y, z = parse_range(r1)
x = int(x)
y = int(y)
z = int(z)
r1 = range(x, y, z)
_, 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: 0
Dangerous Syscalls
input:
ans=0 for a in range(1,3): for b in range(5,1,-2): ans+=b print(ans)