QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647370 | #9255. Python Program | Mu_Silk# | TL | 740ms | 10780kb | Python3 | 1.1kb | 2024-10-17 13:40:10 | 2024-10-17 13:40:11 |
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
ans=0
for i in range(rg1[0],rg1[1],rg1[2]):
l,r,s=rg2
if(tag[0]):l=i
else: l=int(l)
if(tag[1]):r=i
else: r=int(r)
if(tag[2]):s=i
else: s=int(s)
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()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 11ms
memory: 10716kb
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: 10780kb
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: 740ms
memory: 10704kb
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: 156ms
memory: 10764kb
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)