QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84757#1875. Neinsgc_KrySFWA 1590ms3672kbC++141.8kb2023-03-06 18:21:382023-03-06 18:23:30

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-06 18:23:30]
  • 评测
  • 测评结果:WA
  • 用时:1590ms
  • 内存:3672kb
  • [2023-03-06 18:21:38]
  • 提交

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<=100;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<=10;j++)
		{
			for(int to=0;to<=100;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<=20;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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 35ms
memory: 3588kb

input:

1 1

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 35ms
memory: 3588kb

input:

1 8

output:

9

result:

ok answer is '9'

Test #3:

score: 0
Accepted
time: 31ms
memory: 3672kb

input:

1 9

output:

12

result:

ok answer is '12'

Test #4:

score: 0
Accepted
time: 37ms
memory: 3612kb

input:

1 10

output:

13

result:

ok answer is '13'

Test #5:

score: 0
Accepted
time: 160ms
memory: 3612kb

input:

5 1

output:

11112

result:

ok answer is '11112'

Test #6:

score: 0
Accepted
time: 172ms
memory: 3668kb

input:

5 84

output:

11235

result:

ok answer is '11235'

Test #7:

score: 0
Accepted
time: 165ms
memory: 3656kb

input:

5 668

output:

12345

result:

ok answer is '12345'

Test #8:

score: 0
Accepted
time: 172ms
memory: 3580kb

input:

5 733942

output:

2281488

result:

ok answer is '2281488'

Test #9:

score: 0
Accepted
time: 1502ms
memory: 3584kb

input:

18 528599760553218747

output:

30725517742188427234

result:

ok answer is '30725517742188427234'

Test #10:

score: 0
Accepted
time: 1542ms
memory: 3644kb

input:

18 964828716126767591

output:

55758681752658348563

result:

ok answer is '55758681752658348563'

Test #11:

score: 0
Accepted
time: 1490ms
memory: 3656kb

input:

18 401057671700316435

output:

22687686284122211545

result:

ok answer is '22687686284122211545'

Test #12:

score: 0
Accepted
time: 1590ms
memory: 3600kb

input:

18 837286627273865280

output:

48255733668453323265

result:

ok answer is '48255733668453323265'

Test #13:

score: 0
Accepted
time: 1562ms
memory: 3648kb

input:

18 273515582847414124

output:

15116382182883344554

result:

ok answer is '15116382182883344554'

Test #14:

score: 0
Accepted
time: 1472ms
memory: 3648kb

input:

18 55923968082999579

output:

2876461768512185545

result:

ok answer is '2876461768512185545'

Test #15:

score: 0
Accepted
time: 415ms
memory: 3652kb

input:

8 715524960511324231

output:

12022650248772112989

result:

ok answer is '12022650248772112989'

Test #16:

score: 0
Accepted
time: 1314ms
memory: 3616kb

input:

16 151753916084873076

output:

6182363727541142425

result:

ok answer is '6182363727541142425'

Test #17:

score: 0
Accepted
time: 151ms
memory: 3656kb

input:

2 587982875953389216

output:

4754915500630529532

result:

ok answer is '4754915500630529532'

Test #18:

score: 0
Accepted
time: 558ms
memory: 3588kb

input:

10 24211831526938061

output:

410770411555582497

result:

ok answer is '410770411555582497'

Test #19:

score: 0
Accepted
time: 1536ms
memory: 3616kb

input:

18 460440787100486905

output:

26131416714411853682

result:

ok answer is '26131416714411853682'

Test #20:

score: 0
Accepted
time: 484ms
memory: 3604kb

input:

8 896669742674035749

output:

14750223579258782248

result:

ok answer is '14750223579258782248'

Test #21:

score: 0
Accepted
time: 887ms
memory: 3664kb

input:

12 556270735102360402

output:

13827553636696643430

result:

ok answer is '13827553636696643430'

Test #22:

score: 0
Accepted
time: 179ms
memory: 3612kb

input:

2 992499694970876542

output:

8147123087598806742

result:

ok answer is '8147123087598806742'

Test #23:

score: 0
Accepted
time: 575ms
memory: 3584kb

input:

9 191349424180689911

output:

3224103375245122149

result:

ok answer is '3224103375245122149'

Test #24:

score: -100
Wrong Answer
time: 124ms
memory: 3656kb

input:

1 1000000000000000000

output:

7394148928757450176

result:

wrong answer expected '7317596822929805779', found '7394148928757450176'