QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551356#9255. Python Programucup-team3734#RE 477ms10680kbPython3764b2024-09-07 16:34:532024-09-07 16:34:55

Judging History

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

  • [2024-09-07 16:34:55]
  • 评测
  • 测评结果:RE
  • 用时:477ms
  • 内存:10680kb
  • [2024-09-07 16:34:53]
  • 提交

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)

output:


result: