QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720194#1875. NeinsslwcrWA 1ms4012kbC++141.7kb2024-11-07 11:09:302024-11-07 11:09:30

Judging History

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

  • [2024-11-07 11:09:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4012kb
  • [2024-11-07 11:09:30]
  • 提交

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'