QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551480#9255. Python Programucup-team4508#Compile Error//C++14758b2024-09-07 17:04:422024-09-07 17:04:42

Judging History

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

  • [2024-09-07 17:04:42]
  • 评测
  • [2024-09-07 17:04:42]
  • 提交

answer

lis = []
for i in range(5): lis.append(input())
a, b = lis[1: 3]
a=a.strip()
b=b.strip()
def calc(x,y,z):
    sb=0
    if z>0:
        if x<y:
            y-=1
            cnt=(y-x)//z+1
            sb=(x+x+z*(cnt-1))*cnt//2
    else:
        if x>y:
            y+=1
            cnt=(x-y)//(-z)+1
            sb=(x+x+z*(cnt-1))*cnt//2
    return sb
la = a[a.index('(')+1: a.index(')')]
lb = b[b.index('(')+1: b.index(')')]
la = la.split(',')
lb = lb.split(',')
ans=0
for i in range(*map(int,la)):
    def dec(s):
        if s==a[4]:
            return i
        else:
            return int(s)
    x=dec(lb[0])
    y=dec(lb[1])
    if len(lb)==2:
        z=1
    else:
        z=dec(lb[2])
    ans+=calc(x,y,z)
print(ans)

Details

answer.code:1:1: error: ‘lis’ does not name a type
    1 | lis = []
      | ^~~