QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#329595#1875. Neinwsc2008WA 77ms3604kbC++141.2kb2024-02-16 22:29:182024-02-16 22:29:18

Judging History

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

  • [2024-02-16 22:29:18]
  • 评测
  • 测评结果:WA
  • 用时:77ms
  • 内存:3604kb
  • [2024-02-16 22:29:18]
  • 提交

answer

#include<bits/stdc++.h>
typedef __int128 ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
ll k,n,d,ans,a[105],p[105],res,f[500],g[500];
void solve(){
	rep(i,1,36/k){ 
		ll sum=d*i;//枚举 k 位一分段的和
		memset(f,0,sizeof(f));
		f[0]=1;
		rep(j,0,k-1){
			for(ll p=j;p<37;p+=k){
				memset(g,0,sizeof(g));
				rep(o,0,8){
					if(a[p]==-1||a[p]==o){
						rep(z,o,300)g[z]+=f[z-o];
					}
				}
				swap(f,g);
			}
			memset(g,0,sizeof(g));
			rep(o,0,30)g[o]+=f[o*10+sum%10]; 
			swap(f,g);
			sum/=10;
		}
		res+=f[sum];
	}
}
int main(){
	k=read(),n=read();
	d=1;
	rep(i,1,k)d*=10;
	p[0]=1;
	rep(i,1,36)p[i]=p[i-1]*10;
	d--;
	rep(i,0,36)a[i]=-1;
	per(i,36,0){
		a[i]=0;
		ans*=10;
		rep(j,0,8){
			a[i]=j,res=0;
			solve();
			if(res<n)n-=res;
			else break;
			ans++;
		}
	}
	write(ans/d);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 76ms
memory: 3604kb

input:

1 1

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 73ms
memory: 3488kb

input:

1 8

output:

9

result:

ok answer is '9'

Test #3:

score: 0
Accepted
time: 77ms
memory: 3480kb

input:

1 9

output:

12

result:

ok answer is '12'

Test #4:

score: 0
Accepted
time: 76ms
memory: 3576kb

input:

1 10

output:

13

result:

ok answer is '13'

Test #5:

score: 0
Accepted
time: 22ms
memory: 3516kb

input:

5 1

output:

11112

result:

ok answer is '11112'

Test #6:

score: 0
Accepted
time: 19ms
memory: 3592kb

input:

5 84

output:

11235

result:

ok answer is '11235'

Test #7:

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

input:

5 668

output:

12345

result:

ok answer is '12345'

Test #8:

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

input:

5 733942

output:

2281488

result:

ok answer is '2281488'

Test #9:

score: -100
Wrong Answer
time: 39ms
memory: 3604kb

input:

18 528599760553218747

output:

10000000000000000010

result:

wrong answer expected '30725517742188427234', found '10000000000000000010'