QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551369#9255. Python Programucup-team3734#RE 0ms0kbPython3835b2024-09-07 16:37:132024-09-07 16:37:14

Judging History

你现在查看的是最新测评结果

  • [2024-09-07 16:37:14]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-07 16:37:13]
  • 提交

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)

output:


result: