QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#647338#9255. Python ProgramMu_Silk#TL 13ms10712kbPython3878b2024-10-17 13:27:082024-10-17 13:27:09

Judging History

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

  • [2024-10-17 13:27:09]
  • 评测
  • 测评结果:TL
  • 用时:13ms
  • 内存:10712kb
  • [2024-10-17 13:27:08]
  • 提交

answer

import math

def solve():
    s=input()
    l1=input().split(' ')
    l2=input()[4:].split(' ')
    sym=l1[1]

    rg1=list(map(int,l1[3][6:-2].split(','))) 
    if(len(rg1)<3):rg1.append(1)

    rg2=l2[3][6:-2].split(',')
    if(len(rg2)<3):rg2.append('1')

    ans=0
    for i in range(rg1[0],rg1[1],rg1[2]):
        l,r,s=rg2
        if(l==sym):l=i
        else: l=int(l)

        if(r==sym):r=i
        else: r=int(r)

        if(s==sym):s=i
        else: s=int(s)

        l1,r1,cnt=0,abs(r-l)+1,0
        while(r1>=l1):
            m=(l1+r1)>>1
            if (s>0 and l+s*(m-1)<r) or (s<0 and l+s*(m-1)>r):
                cnt=m
                l1=m+1
            else:
                r1=m-1
        # print(l,r,s,cnt)
        ans+=(l+l+(cnt-1)*s)*cnt//2

    print(ans)

_=1
# _=int(input())
while(_>0):
    _-=1
    solve()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 10640kb

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: 6ms
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: