QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352287#7996. 报数 IVKevin5307WA 8ms74248kbC++20890b2024-03-13 08:04:532024-03-13 08:04:54

Judging History

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

  • [2024-03-13 08:04:54]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:74248kb
  • [2024-03-13 08:04:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[1005][9005][2];
void upd(int &a,int b)
{
	a+=b;
	if(a>=mod)
		a-=mod;
}
int d(int x,int k)
{
	while(k&&x>=10)
	{
		int tmp=x;
		x=0;
		while(tmp)
		{
			x+=tmp%10;
			tmp/=10;
		}
		k--;
	}
	return x;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		string n;
		int k,m;
		cin>>n>>k>>m;
		memset(dp,0,sizeof(dp));
		dp[0][0][1]=1;
		for(int i=0;i<n.length();i++)
			for(int j=0;j<=9*i;j++)
				for(int k=0;k<2;k++)
					for(int x=0;x<10;x++)
						if(x<=(n[i]^48)||!k)
							upd(dp[i+1][j+x][k&&(x==n[i]^48)],dp[i][j][k]);
		int ans=0;
		for(int j=0;j<=n.length()*9;j++)
			if(d(j,k-1)==m)
			{
				upd(ans,dp[n.length()][j][0]);
				upd(ans,dp[n.length()][j][1]);
			}
		cout<<ans<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 74248kb

input:

2
114 1 5
514 2 10

output:

3
0

result:

wrong answer 1st lines differ - expected: '8', found: '3'