QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#34393 | #1875. Nein | feecle6418 | WA | 56ms | 4192kb | C++20 | 1.3kb | 2022-06-08 15:16:00 | 2022-06-08 15:16:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef __uint128_t LL;
typedef pair<int,int> pr;
const int mod=998244353;
ll n;
int m;
LL f[45][405],g[45][405],pw[45]={1};
int floor_div(int x,int y){
if(x<0)return (x-y+1)/y;
return x/y;
}
int main(){
cin>>m>>n,n++,g[0][0]=1;
for(ll i=1;i<=38;i++){
for(ll j=0;j<=i*8;j++)for(ll k=0;k<=j&&k<=8;k++)g[i][j]+=g[i-1][j-k];
}
LL t=1;
for(ll i=1;i<=m;i++)t*=10;
t--;
for(ll i=1;i<=38;i++)pw[i]=pw[i-1]*10;
LL ans=0,rem=0;
for(int i=38;i>=0;i--){
ll x;
for(x=0;x<=9;x++){
rem=(ans*10+x)%t*(pw[i]%t)%t,rem=(t-rem)%t;
//cout<<(ll)rem<<'\n';
ll cnt[45]={0},all=0;
for(ll j=0;j<i;j++)cnt[j%m]++;
for(ll j=0;j<=floor_div(i-1,m)+1;j++){
LL sum=rem+j*t,dig[45]={0},ts=0;
while(sum)dig[++ts]=sum%10,sum/=10;
memset(f,0,sizeof(f)),f[0][0]=1;
for(ll k=0;k<ts;k++){
for(ll l=0;l<i*8;l++){
for(ll p=0;p<=cnt[k]*8;p++){
if((l+p)%10!=dig[k+1])continue;
f[k+1][(l+p)/10]+=f[k][l]*g[cnt[k]][p];
}
}
}
all+=f[ts][0];
}
if(n>all)n-=all;
else break;
}
//cout<<i<<'\n';
ans=ans*10+x;
//cout<<i<<' '<<(ll)ans<<' '<<(ll)t<<'\n';
}
assert(ans%t==0);
cout<<(ll)(ans/t);
}
詳細信息
Test #1:
score: 100
Accepted
time: 56ms
memory: 4092kb
input:
1 1
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 55ms
memory: 4016kb
input:
1 8
output:
9
result:
ok answer is '9'
Test #3:
score: 0
Accepted
time: 52ms
memory: 4088kb
input:
1 9
output:
12
result:
ok answer is '12'
Test #4:
score: 0
Accepted
time: 55ms
memory: 4092kb
input:
1 10
output:
13
result:
ok answer is '13'
Test #5:
score: 0
Accepted
time: 11ms
memory: 4028kb
input:
5 1
output:
11112
result:
ok answer is '11112'
Test #6:
score: 0
Accepted
time: 15ms
memory: 4012kb
input:
5 84
output:
11235
result:
ok answer is '11235'
Test #7:
score: 0
Accepted
time: 16ms
memory: 4192kb
input:
5 668
output:
12345
result:
ok answer is '12345'
Test #8:
score: 0
Accepted
time: 16ms
memory: 4084kb
input:
5 733942
output:
2281488
result:
ok answer is '2281488'
Test #9:
score: -100
Wrong Answer
time: 30ms
memory: 4120kb
input:
18 528599760553218747
output:
12278773668478875618
result:
wrong answer expected '30725517742188427234', found '12278773668478875618'