QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84572#1875. Nein_UMqwq_WA 30ms5704kbC++142.1kb2023-03-06 15:57:152023-03-06 15:57:16

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 15:57:16]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:5704kb
  • [2023-03-06 15:57:15]
  • 提交

answer

#include<bits/stdc++.h>
#define int __int128
using namespace std;
namespace IO{
    char buff[1<<21],*p1=buff,*p2=buff;
    char getch(){
        return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;
    }
    template<typename T>
    void read(T &x){
        char ch=getch();int fl=1;x=0;
        while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}
        while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}
        x*=fl;
    }
    template<typename T,typename ...Args>
    void read(T &x,Args& ...args){
        read(x);read(args...);
    }
    char obuf[1<<21],*p3=obuf;
    void putch(char ch){
        if(p3-obuf<(1<<21))*p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    char ch[100];
    template<typename T>
    void write(T x){
    	if(!x)return putch('0');
        if(x<0)putch('-'),x*=-1;
        int top=0;
        while(x)ch[++top]=x%10+48,x/=10;
        while(top)putch(ch[top]),top--;
    }
    template<typename T,typename ...Args>
    void write(T x,Args ...args){
        write(x);write(args...);
    }
    void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
int n,m,K,B,ans;
int f[40][40],g[40][400],pw[40];
int calc(int pos,int x){
	int r=(m-(ans+pw[pos]*x)%m)%m,ret=0;
	for(int t=0;t<B;t++){
		int now=t*m+r;
		memset(f,0,sizeof(f));f[0][0]=1;
		for(int i=1;i<=K;i++)
			for(int j=0;j<B;j++)
				for(int k=0;k<B;k++){
					int bit=(now/pw[i-1])%10;
					int del=k*10+bit-j;if(del<0)continue;
					f[i][k]+=f[i-1][j]*g[(pos-i+K)/K][del];
				}
		ret+=f[K][now/pw[K]];
	}return ret;
}
signed main(){
	pw[0]=1;for(int i=1;i<=36;i++)pw[i]=pw[i-1]*10;
	g[0][0]=1;
	for(int i=1;i<=36;i++)
		for(int j=0;j<400;j++)
			for(int k=0;k<9&&k<=j;k++)
				g[i][j]+=g[i-1][j-k];
	read(K,n);n++;B=36/K;m=pw[K]-1;
	for(int i=B*K-1;i>=0;i--)
		for(int j=0;j<9;j++){
			int cnt=calc(i,j);//write(i);putch(' ');write(j);putch(' ');write(cnt);putch('\n');
			if(cnt>=n){ans+=pw[i]*j;break;}
			else n-=cnt;
		}//write(ans);putch('\n');
	write(ans/m);flush();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 26ms
memory: 5564kb

input:

1 1

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 29ms
memory: 5576kb

input:

1 8

output:

9

result:

ok answer is '9'

Test #3:

score: 0
Accepted
time: 30ms
memory: 5552kb

input:

1 9

output:

12

result:

ok answer is '12'

Test #4:

score: 0
Accepted
time: 26ms
memory: 5704kb

input:

1 10

output:

13

result:

ok answer is '13'

Test #5:

score: 0
Accepted
time: 2ms
memory: 5640kb

input:

5 1

output:

11112

result:

ok answer is '11112'

Test #6:

score: 0
Accepted
time: 4ms
memory: 5584kb

input:

5 84

output:

11235

result:

ok answer is '11235'

Test #7:

score: 0
Accepted
time: 4ms
memory: 5704kb

input:

5 668

output:

12345

result:

ok answer is '12345'

Test #8:

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

input:

5 733942

output:

2281488

result:

ok answer is '2281488'

Test #9:

score: -100
Wrong Answer
time: 4ms
memory: 5640kb

input:

18 528599760553218747

output:

0

result:

wrong answer expected '30725517742188427234', found '0'