QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#844521#9255. Python Programhxu10#AC ✓352ms10768kbPython31011b2025-01-06 02:05:362025-01-06 02:05:36

Judging History

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

  • [2025-01-06 02:05:36]
  • 评测
  • 测评结果:AC
  • 用时:352ms
  • 内存:10768kb
  • [2025-01-06 02:05:36]
  • 提交

answer



def getparam(s):   
#    print(s)
    s = s.split(",")
    if len(s)==2:
        s[1] = s[1][:-2]
        s.append("1):")
    v1 = s[0][6:]
    v2 = s[1]
    v3 = s[2][:-2]
    return [v1,v2,v3]



def evaluate(a,b,c):
    
    count = (b - a - 1)//c + 1

    if c > 0:
        count = (b - a - 1)//c + 1
    else:
        count = (a - b - 1)//(-c) + 1
        
    if count <= 0:
        return 0
 
    res = a * count + count * (count - 1) // 2 * c
    return res    
        

def main():

    s = input()
    p1 = getparam(input().split()[3])
    p2 = getparam(input().split()[3])
    s = input()
    s = input()
    
    v = -1
    
    for i in range(3):
        p1[i] = int(p1[i])
        try:
            
            p2[i] = int(p2[i]) 
        except:
            v = i
#    print(p1)
#    print(p2)

    ans = 0
    for i in range(p1[0],p1[1],p1[2]):
        if v >= 0:   p2[v] = i
#        print(p2)
        ans += evaluate(p2[0],p2[1],p2[2])

    print(ans)
        
        

    







main()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 10712kb

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: 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: 0
Accepted
time: 352ms
memory: 10768kb

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: 61ms
memory: 10704kb

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: 332ms
memory: 10696kb

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