QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#84765 | #1875. Nein | sgc_KrySF | WA | 1607ms | 3704kb | C++14 | 1.8kb | 2023-03-06 18:25:08 | 2023-03-06 18:25:37 |
Judging History
answer
#include<bits/stdc++.h>
#define int __int128
#define LL long long
using namespace std;
const int Inf=1e18+1;
inline int read()
{
int sum=0,f=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}
while(isdigit(ch)){sum=sum*10+ch-48;ch=getchar();}
return sum*f;
}
int f[51][101];
int Ans[55];
int n,K,d;
int T,t;
int s[55];
int settled[55];
int unset[55];
int bs[55][505];
bool put;
void init()
{
bs[0][0]=1;
for(int i=1;i<=36;i++)
for(int j=0;j<=120;j++)
{
for(int k=0;k<=min((int)8,j);k++)
{
if(bs[i][j]>1e18)break;
bs[i][j]+=bs[i-1][j-k];
}
if(bs[i][j]>Inf) bs[i][j]=Inf;
}
}
bool CH=0;
int dp()
{
memset(f,0,sizeof(f));
f[0][0]=1;
for(int i=1;i<=d+1;i++)
{
for(int j=0;j<=12;j++)
{
for(int to=0;to<=120;to++)
{
if((j+to+settled[i-1])%10!=s[i-1]) continue;
f[i][(to+j+settled[i-1])/10]+=f[i-1][j]*bs[unset[i-1]][to];
}
}
}
if(d==-1)
{
if(!puts) return 1;
return 0;
}
return f[d+1][0];
}
int count()
{
int ssum=0;
for(int p=0;p<=15;p++)
{
memset(s,0,sizeof(s));
t=T*p;
d=0;
while(t)
{
s[d]=t%10;
d++;
t/=10;
}
d--;
int sum=dp();
ssum+=sum;
if(ssum>Inf) return ssum;
}
return ssum;
}
void write(int x)
{
if(x)
{
write(x/10);
putchar(x%10+48);
}
}
signed main()
{
init();
K=read(),n=read();
T=1;for(int g=1;g<=K;g++) T*=10;T--;
for(int i=0;i<=37;i++) unset[i%K]++;
for(int i=37;i>=0;i--)
{
unset[i%K]--;
for(int j=0;j<9;j++)
{
settled[i%K]+=j;
if(i==2&&j==0) CH=1;
int g=count();
if(g>=n){put|=(j>0);Ans[i]=j;break;}
else n-=count(),settled[i%K]-=j;
}
}
bool flgg=0;
int TTT=0;
for(int i=37;i>=0;i--)
{
TTT=TTT*10+Ans[i];
}
write(TTT/T);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 34ms
memory: 3684kb
input:
1 1
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 32ms
memory: 3704kb
input:
1 8
output:
9
result:
ok answer is '9'
Test #3:
score: 0
Accepted
time: 35ms
memory: 3588kb
input:
1 9
output:
12
result:
ok answer is '12'
Test #4:
score: 0
Accepted
time: 34ms
memory: 3600kb
input:
1 10
output:
13
result:
ok answer is '13'
Test #5:
score: 0
Accepted
time: 161ms
memory: 3624kb
input:
5 1
output:
11112
result:
ok answer is '11112'
Test #6:
score: 0
Accepted
time: 163ms
memory: 3604kb
input:
5 84
output:
11235
result:
ok answer is '11235'
Test #7:
score: 0
Accepted
time: 159ms
memory: 3676kb
input:
5 668
output:
12345
result:
ok answer is '12345'
Test #8:
score: 0
Accepted
time: 167ms
memory: 3628kb
input:
5 733942
output:
2281488
result:
ok answer is '2281488'
Test #9:
score: 0
Accepted
time: 1533ms
memory: 3632kb
input:
18 528599760553218747
output:
30725517742188427234
result:
ok answer is '30725517742188427234'
Test #10:
score: 0
Accepted
time: 1586ms
memory: 3600kb
input:
18 964828716126767591
output:
55758681752658348563
result:
ok answer is '55758681752658348563'
Test #11:
score: 0
Accepted
time: 1526ms
memory: 3624kb
input:
18 401057671700316435
output:
22687686284122211545
result:
ok answer is '22687686284122211545'
Test #12:
score: 0
Accepted
time: 1591ms
memory: 3664kb
input:
18 837286627273865280
output:
48255733668453323265
result:
ok answer is '48255733668453323265'
Test #13:
score: 0
Accepted
time: 1590ms
memory: 3624kb
input:
18 273515582847414124
output:
15116382182883344554
result:
ok answer is '15116382182883344554'
Test #14:
score: 0
Accepted
time: 1502ms
memory: 3660kb
input:
18 55923968082999579
output:
2876461768512185545
result:
ok answer is '2876461768512185545'
Test #15:
score: 0
Accepted
time: 424ms
memory: 3608kb
input:
8 715524960511324231
output:
12022650248772112989
result:
ok answer is '12022650248772112989'
Test #16:
score: 0
Accepted
time: 1344ms
memory: 3680kb
input:
16 151753916084873076
output:
6182363727541142425
result:
ok answer is '6182363727541142425'
Test #17:
score: 0
Accepted
time: 154ms
memory: 3620kb
input:
2 587982875953389216
output:
4754915500630529532
result:
ok answer is '4754915500630529532'
Test #18:
score: 0
Accepted
time: 569ms
memory: 3600kb
input:
10 24211831526938061
output:
410770411555582497
result:
ok answer is '410770411555582497'
Test #19:
score: 0
Accepted
time: 1607ms
memory: 3624kb
input:
18 460440787100486905
output:
26131416714411853682
result:
ok answer is '26131416714411853682'
Test #20:
score: 0
Accepted
time: 499ms
memory: 3600kb
input:
8 896669742674035749
output:
14750223579258782248
result:
ok answer is '14750223579258782248'
Test #21:
score: 0
Accepted
time: 950ms
memory: 3648kb
input:
12 556270735102360402
output:
13827553636696643430
result:
ok answer is '13827553636696643430'
Test #22:
score: 0
Accepted
time: 180ms
memory: 3616kb
input:
2 992499694970876542
output:
8147123087598806742
result:
ok answer is '8147123087598806742'
Test #23:
score: 0
Accepted
time: 555ms
memory: 3624kb
input:
9 191349424180689911
output:
3224103375245122149
result:
ok answer is '3224103375245122149'
Test #24:
score: -100
Wrong Answer
time: 97ms
memory: 3620kb
input:
1 1000000000000000000
output:
7317827445671378082
result:
wrong answer expected '7317596822929805779', found '7317827445671378082'