QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32734#1875. NeinWu_RenRE 3ms3824kbC++171.0kb2022-05-23 09:13:402022-05-23 09:13:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-23 09:13:41]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:3824kb
  • [2022-05-23 09:13:40]
  • 提交

answer

#include <bits/stdc++.h>
typedef long long ll;
typedef __int128 lll;
using namespace std;
int K,B,a[30];
ll n,_k[20],M,R;
lll g[30][200],f[30][30];
lll calc(int m){
	lll r=R,res=0;
	for(int _=0;_<B-1;_++,r+=M){
		memset(f,0,sizeof(f)),f[0][0]=1;
		for(int i=0;i<K;i++){
			int c=m/K+(m%K>i);
			for(int j=0;j<B;j++) if(f[i][j]){
				for(int k=0;k<B;k++){
					int s=k*10+(r/_k[i])%10-j;
					if(s<0||s>8*c) continue;
					f[i+1][k]+=f[i][j]*g[c][s];
				}
			}
		}
		res+=f[K][r/_k[K]];
	}
	return res;
}
void putc(lll x){
	if(x>=10) putc(x/10);
	putchar(x%10+'0');
}
int main(){
	scanf("%d%lld",&K,&n),B=2+20/K;
	for(int i=_k[0]=1;i<=K;i++) _k[i]=10*_k[i-1];
	M=_k[K]-1;
	for(int i=g[0][0]=1;i<=22;i++){
		for(int j=0;j<=i*8;j++) for(int k=0;k<9;k++) if(j>=k) g[i][j]+=g[i-1][j-k];
	}
	R=0;
	lll xM=0;
	for(int i=K*B-1;i>=0;i--){
		for(int j=0;j<9;j++){
			a[i]=j;
			lll t=calc(i);
			if(n<t) break;
			n-=t;
			R-=_k[i%K];
			if(R<0) R+=M;
		}
		xM=10*xM+a[i];
	}
	xM/=M;
	putc(xM);puts("");
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3728kb

input:

1 1

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

1 8

output:

9

result:

ok answer is '9'

Test #3:

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

input:

1 9

output:

12

result:

ok answer is '12'

Test #4:

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

input:

1 10

output:

13

result:

ok answer is '13'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

5 1

output:

11112

result:

ok answer is '11112'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

5 84

output:

11235

result:

ok answer is '11235'

Test #7:

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

input:

5 668

output:

12345

result:

ok answer is '12345'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

5 733942

output:

2281488

result:

ok answer is '2281488'

Test #9:

score: -100
Runtime Error

input:

18 528599760553218747

output:


result: