QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#550532#9255. Python Programucup-team133#AC ✓712ms11132kbPython31.2kb2024-09-07 13:21:572024-09-07 13:22:01

Judging History

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

  • [2024-09-07 13:22:01]
  • 评测
  • 测评结果:AC
  • 用时:712ms
  • 内存:11132kb
  • [2024-09-07 13:21:57]
  • 提交

answer

import sys,time

from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

S = input()

Fi = input()
Fi_split = Fi.split(" ")
Fi_var = Fi_split[1]
Fi_range = Fi_split[3]
Fi_left,Fi_right = Fi_range.index('('),Fi_range.index(')')
Fi_abc = Fi_range[Fi_left+1:Fi_right].split(",")

Fj = input()
Fj_split = Fj.split(" ")
Fj_var = Fj_split[5]
Fj_range = Fj_split[7]
Fj_left,Fj_right = Fj_range.index('('),Fj_range.index(')')
Fj_def = Fj_range[Fj_left+1:Fj_right].split(",")

if len(Fi_abc) == 2:
    Fi_abc.append("1")
if len(Fj_def) == 2:
    Fj_def.append("1")
a,b,c = map(int,Fi_abc)

ans = 0
for i in range(a,b,c):
    d,e,f = [int(x) if x!=Fi_var else i for x in Fj_def]
    #for j in range(d,e,f):
        #ans += j
    
    if 0 < f:
        k_max = (e-d-1)//f
        if k_max < 0:
            continue
        ans += d * (k_max+1) + f * k_max * (k_max+1)//2
    else:
        k_max = (d-(e+1))//(-f)
        if k_max < 0:
            continue
        ans += d * (k_max+1) + f * k_max * (k_max+1)//2
print(ans)
    


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 16ms
memory: 11024kb

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: 11080kb

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: 712ms
memory: 11080kb

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: 142ms
memory: 11076kb

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: 706ms
memory: 11132kb

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