QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88380#5460. Sum of NumbersYangmfCompile Error//C++141.4kb2023-03-16 09:17:482023-03-16 09:17:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-16 09:17:50]
  • 评测
  • [2023-03-16 09:17:48]
  • 提交

answer

# [n,k]=map(int(),input().split(' '))
# print(n,k)
global cnt
global n,k
cnt = 0
N = 200010
dp = [[-1 for j in range(6+3)] for i in range(N)]
sum = [0 for i in range(N)]
dd = [0 for i in range(N)]
lens = [[-1 for j in range(8)] for i in range(800)]
tmp = [-1 for i in range(8)]
def get(l,r,num):
    res = 0
    for i in range(l,r+1):
        res*=10
        res+=int(num[i])
    return res
def dfs(len,bk,d,mx):
    global n, k
    global cnt
    if d>=mx:
        if(len!=n):
            return
        cnt = cnt + 1
        for i in range(mx):
            lens[cnt][i] = tmp[i]
    else :
        for i in range(-1,2):
            tmp[d] = bk+i
            dfs(len+bk+i,bk,d+1,mx)



def main():
    global n,k,cnt
    cnt=0
    n,k = map(int,input().split())
    # print(n,k)
    num = input()
    ans = int(num)
    num='.'+num
    bk = n//(k+1)
    dfs(0,bk,0,k+1)
    dd[n]=1
    dd[n+1]=1
    for i in range(n,0,-1):
        sum[i]=sum[i+1]+int(num[i])*dd[i]
        dd[i-1]=dd[i]*10
    for i in range(1,cnt+1):
        res = 0
        len = 0
        for j in range(0,k+1):
            xx = lens[i][j]
            res = res+(sum[len+1]-sum[len+xx+1])//dd[len+xx]
            len += xx
        ans=min(ans,res)
    print(ans)
    for i in range(0,n+3):
        sum[i]=dd[i]=0


if __name__ == "__main__":
    t = int(input())
    while t!=0:
        main()
        t=t-1

詳細信息

answer.code:1:3: error: invalid preprocessing directive #[
    1 | # [n,k]=map(int(),input().split(' '))
      |   ^
answer.code:2:3: error: invalid preprocessing directive #print
    2 | # print(n,k)
      |   ^~~~~
answer.code:38:7: error: invalid preprocessing directive #print
   38 |     # print(n,k)
      |       ^~~~~
answer.code:3:1: error: ‘global’ does not name a type
    3 | global cnt
      | ^~~~~~