QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#552014#9255. Python Programucup-team3670#TL 17ms10712kbPython3574b2024-09-07 19:48:182024-09-07 19:48:19

Judging History

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

  • [2024-09-07 19:48:19]
  • 评测
  • 测评结果:TL
  • 用时:17ms
  • 内存:10712kb
  • [2024-09-07 19:48:18]
  • 提交

answer

def parse(s):
	i = s.split()[1]
	s = s.split('(')[-1]
	s = s.split(')')[0]
	s = s.split(',')
	if len(s) == 2:
		s.append('1')
	return [i] + s

exec(input())
s = parse(input().strip())
t = parse(input().strip())
for it in range(int(s[1]), int(s[2]), int(s[3])):
	exec(s[0] + '=' + str(it))
	lf = eval(t[1])
	rg = eval(t[2])
	st = eval(t[3])
	coef = 1
	if st < 0:
		lf = -lf
		rg = -rg
		st = -st
		coef = -1
	rg -= 1
	if lf <= rg:
		fst = lf
		cnt = (rg - lf) // st
		lst = fst + cnt * st
		ans += coef * ((fst + lst) * (cnt + 1) // 2)
print(ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 10612kb

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: 17ms
memory: 10712kb

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: