QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647384 | #9255. Python Program | Mu_Silk# | AC ✓ | 550ms | 10768kb | Python3 | 1.1kb | 2024-10-17 13:46:56 | 2024-10-17 13:46:57 |
Judging History
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+1)
if(s>0):
while(l+s*(cnt-1)<r):cnt+=1
while(cnt>=0 and l+s*(cnt-1)>=r):cnt-=1
else:
while(l+s*(cnt-1)>r):cnt+=1
while(cnt>=0 and 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()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
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: 10ms
memory: 10588kb
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: 550ms
memory: 10700kb
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: 92ms
memory: 10768kb
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: 545ms
memory: 10692kb
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