QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606953#9255. Python Programpropane#TL 17ms10572kbPython3856b2024-10-03 13:12:552024-10-03 13:12:55

Judging History

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

  • [2024-10-03 13:12:55]
  • 评测
  • 测评结果:TL
  • 用时:17ms
  • 内存:10572kb
  • [2024-10-03 13:12:55]
  • 提交

answer

s = input()
s = input()
a, b, c = 0, 0, 1

s = s[s.find('(') + 1: s.find(')')]

lst = tuple(map(int, s.split(',')))
if len(lst) == 2:
    a, b = lst
else:
    a, b, c = lst

s = input()

lst = (s[s.find('(') + 1: s.find(')')]).split(',')

ans = 0

for i in range(a, b, c):
    v = [0, 0, 1]
    for j in range(len(lst)):
        if (lst[j][0].isalpha()):
            v[j] = i
        else:
            v[j] = int(lst[j])
            
    if v[2] > 0:
        v[1] -= 1
        if v[1] >= v[0]:
            v[1] = (v[1] - v[0]) // v[2] * v[2] + v[0]
            ans += (v[0] + v[1]) * ((v[1] - v[0]) // v[2] + 1) // 2
    else:
        v[1] += 1
        if v[1] <= v[0]:
            v[1] = v[0] - (v[0] - v[1]) // abs(v[2]) * abs(v[2])
            ans += (v[0] + v[1]) * ((v[0] - v[1]) // abs(v[2]) + 1) // 2
print(ans)

詳細信息

Test #1:

score: 100
Accepted
time: 17ms
memory: 10572kb

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: 10ms
memory: 10572kb

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)

output:


result: