QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#609858 | #9255. Python Program | ucup-team1001# | AC ✓ | 859ms | 11304kb | Python3 | 674b | 2024-10-04 14:16:01 | 2024-10-04 14:16:02 |
Judging History
answer
#S = input()
import re
import math
L1 = input()
L2 = input()
l2 = re.split('\(|,|\)', L2)
a = int(l2[1])
b = int(l2[2])
c = 1
if l2[3] != ':':
c = int(l2[3])
L3 = input()
l3 = re.split('\(|,|\)', L3)
def solve(l, r, d):
k = (r - l)
if d > 0: k -= 1
else: k += 1
k = k // d
return max((l + l + k * d) * (k + 1) // 2, 0)
def get(p, i):
if p[0] >= 'a' and p[0] <= 'z':
return i
if p[0] == ':':
return 1
return int(p)
ans = int(0)
for i in range(a, b, c):
dd = get(l3[1], i)
ee = get(l3[2], i)
ff = get(l3[3], i)
ans += solve(dd, ee, ff)
print(int(ans))
详细
Test #1:
score: 100
Accepted
time: 16ms
memory: 11300kb
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: 12ms
memory: 11124kb
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: 852ms
memory: 11304kb
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: 0
Accepted
time: 156ms
memory: 11300kb
input:
ans=0 for i in range(31,321983,2): for j in range(313,382193): ans+=j print(ans)
output:
11756963404587200
result:
ok single line: '11756963404587200'
Test #5:
score: 0
Accepted
time: 859ms
memory: 11116kb
input:
ans=0 for i in range(1,1000000): for j in range(i,114514,-1): ans+=j print(ans)
output:
160610445975856765
result:
ok single line: '160610445975856765'
Extra Test:
score: 0
Extra Test Passed