QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#720194 | #1875. Nein | sslwcr | WA | 1ms | 4012kb | C++14 | 1.7kb | 2024-11-07 11:09:30 | 2024-11-07 11:09:30 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<array>
#include<bits/stdc++.h>
#define int __int128
#define mod 1000000007ll
using namespace std;
inline int read()
{
int ret,c,f=1;
while (((c=getchar())> '9'||c< '0')&&c!='-');
if (c=='-') f=-1,ret=0;
else ret=c-'0';
while ((c=getchar())>='0'&&c<='9') ret=ret*10+c-'0';
return ret*f;
}
int n,k,f[120][120],a[120],V;
int ans,g[120][240];
int gt(int wei,int s)
{
memset(g,0,sizeof(g));
g[0][0]=1;
int mx=0;
for (int i=0;i<k;i++,s/=10)
{
for (int j=i;j<=wei;j+=k)
{
if (a[j]!=-1)
{
s-=a[j];
if (s<0) return 0;
}
else
{
mx+=8;
for (int nw=mx;nw>=0;nw--)
{
for (int v=1;v<=8&&v<=nw;++v) g[i][nw]+=g[i][nw-v];
}
}
}
int nemx=0;
for (int nw=s%10;nw<=mx;nw+=10) g[i+1][nw/10]=g[i][nw],nemx=nw/10;
mx=nemx;
}
return g[k][s];
}
int gv(int wei)
{
int ans=0;
for (int i=0;i<=40;i++)
{
ans+=gt(wei,V*i);
}
return ans;
}
void wr(int x,bool fl=1)
{
if (fl&&x==0)
{
putchar('0');
return;
}
if (x==0) return;
wr(x/10,0);
putchar(48+x%10);
return;
}
signed main()
{
k=read(),n=read();
V=1;
for (int i=1;i<=k;i++) V=V*10;
V--;
int le;
for (int i=0;i<120;i++)
{
for (int j=0;j<i;j++) a[j]=-1;
a[i]=0;
le=i-1;
if (gv(i)>=n) break;
}
int anss=0;
for (int i=le;i>=0;--i)
{
for (int p=0;p<9;p++)
{
a[i]=p;
int v=gv(le);
if (v>n)
{
break;
}
else n-=v;
}
}
for (int i=le;i>=0;i--) anss=anss*10+a[i];
wr(anss/V);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4012kb
input:
1 1
output:
0
result:
wrong answer expected '2', found '0'