QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#647375#9255. Python ProgramMu_Silk#TL 564ms10708kbPython31.1kb2024-10-17 13:42:082024-10-17 13:42:09

Judging History

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

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

answer

import math

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

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

    rg2=l2[3][6:-2].split(',')
    if(len(rg2)<3):rg2.append('1')
    elif(rg2[2]!=sym and len(rg2[2])>10):
        print(0)
        return
    
    tag=[0,0,0]
    for i in range(3):
        if(rg2[i]==sym):tag[i]=1
        else: rg2[i]=int(rg2[i])
    
    ans=0
    for i in range(rg1[0],rg1[1],rg1[2]):
        l,r,s=rg2
        if(tag[0]):l=i
        if(tag[1]):r=i
        if(tag[2]):s=i

        cnt=max(0,(r-l)//s)
        if(s>0):
            while(l+s*(cnt-1)<r):cnt+=1
            while(l+s*(cnt-1)>=r):cnt-=1
        else:
            while(l+s*(cnt-1)>r):cnt+=1
            while(l+s*(cnt-1)<=r):cnt-=1
        # print(l,r,s,cnt)
        cnt=max(0,cnt)
        ans+=(l+l+(cnt-1)*s)*cnt//2

    print(ans)

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

详细

Test #1:

score: 100
Accepted
time: 9ms
memory: 10708kb

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: 11ms
memory: 10688kb

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: 564ms
memory: 10688kb

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: 105ms
memory: 10600kb

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: -100
Time Limit Exceeded

input:

ans=0
for i in range(1,1000000):
    for j in range(i,114514,-1):
        ans+=j
print(ans)

output:


result: