QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#440315#1875. NeinKalenistWA 24ms4108kbC++201.1kb2024-06-13 15:59:392024-06-13 15:59:41

Judging History

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

  • [2024-06-13 15:59:41]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:4108kb
  • [2024-06-13 15:59:39]
  • 提交

answer

#include<bits/stdc++.h>
#define LL __int128
#define N 25
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define Down(i,a,b) for(register int i=a;i>=b;i--)
using namespace std;
int m,nv,lim,mx;
LL n,g[N][N*10],pw[N];
LL f[N][N*10],nw,r,p,ans;
inline void print(LL x){if(!x) return;print(x/10),putchar(x%10+'0');}
inline LL dp(int nlen)
{
    LL res=0;
    For(c,0,lim)
    {
        memset(f,0,sizeof(f));
        LL nr=p*c+r;f[m][nr/pw[m]]=1;
        Down(i,m,1) For(j,0,mx) For(k,0,mx)
        {
            int nxt=j*10+nr/pw[i-1]%10-k;
            if(nxt >= 0 && nxt <= mx) 
                f[i-1][nxt]+=f[i][j]*g[nlen/m+(nlen%m>=i)][k];
        }res+=f[0][0];
    }
    return res;
}

int main()
{
    scanf("%d%lld",&m,&n);
    pw[0]=g[0][0]=1,n++;
    For(i,1,20) pw[i]=pw[i-1]*10;
    lim=19/m+1,p=pw[m]-1,mx=(lim+3)*8;
    For(i,0,19) For(j,0,i*8) 
        For(k,0,8) g[i+1][j+k]+=g[i][j];
    Down(i,20,0) 
    {
        for(nv=0;nv<=9;nv++)
            if((nw=dp(i)) >= n) break;
            else n-=nw,r=(r+p-pw[i%m])%p;
        ans+=pw[i]*nv;
    }print(ans/p);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 23ms
memory: 3856kb

input:

1 1

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 23ms
memory: 4076kb

input:

1 8

output:

9

result:

ok answer is '9'

Test #3:

score: 0
Accepted
time: 24ms
memory: 3824kb

input:

1 9

output:

12

result:

ok answer is '12'

Test #4:

score: 0
Accepted
time: 23ms
memory: 3776kb

input:

1 10

output:

13

result:

ok answer is '13'

Test #5:

score: 0
Accepted
time: 6ms
memory: 3848kb

input:

5 1

output:

11112

result:

ok answer is '11112'

Test #6:

score: 0
Accepted
time: 7ms
memory: 4108kb

input:

5 84

output:

11235

result:

ok answer is '11235'

Test #7:

score: 0
Accepted
time: 7ms
memory: 3820kb

input:

5 668

output:

12345

result:

ok answer is '12345'

Test #8:

score: 0
Accepted
time: 3ms
memory: 3840kb

input:

5 733942

output:

2281488

result:

ok answer is '2281488'

Test #9:

score: -100
Wrong Answer
time: 19ms
memory: 3840kb

input:

18 528599760553218747

output:

1111

result:

wrong answer expected '30725517742188427234', found '1111'