QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#713396#7996. 报数 IVsdmrlhWA 200ms74028kbC++141.5kb2024-11-05 19:13:472024-11-05 19:13:49

Judging History

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

  • [2024-11-05 19:13:49]
  • 评测
  • 测评结果:WA
  • 用时:200ms
  • 内存:74028kb
  • [2024-11-05 19:13:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld%lld",&x,&y)
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pf(x) printf("%lld",x)
#define pii pair<int,int> 
#define s second
#define int long long



//
//
const int mod = 1e9+7;
string ss;
map<int,int> mp[5];
int op[5]={0,9000,35,11,9};

void caozuo(int u)
{
	if(!mp[u].size()) return ;
	
	for(int i=1;i<=op[u-1];i++)
	{
		int now =i;
		int sum=0;
		while(now)
		{
			sum+=now%10;
			now/=10;
		}
		if(mp[u].count(sum)) mp[u-1][i]=1;
	}
}
int f[1010][9010];

void init()
{
	f[0][0]=1;
	for(int i=1;i<=9;i++) f[1][i]=1;
	for(int i=2;i<=1000;i++)
		for(int j=1;j<=9000;j++){
			for(int k=0;k<=9;k++)
				if(j>=k) f[i][j]=(f[i][j]+f[i-1][j-k])%mod;
				f[i][j]=(f[i-1][j]+f[i][j])%mod;
				f[i][0]=1;
			}
}

int dp(int x)
{
	int last=0,sum=0;
	for(int i=0;i<ss.size();i++)
	{
		int n = ss[i]-'0';
		for(int j=0;j<n;j++){
			if(x-last-j>=0)
			sum=(sum+f[ss.size()-i-1][x-last-j])%mod;
		}
		last+=n;
		if(i==(int)ss.size()-1) if(last==x) sum++;
	}
	return sum%mod;
}

void solve()
{
	for(int i=0;i<=4;i++) mp[i].clear();
	int m,k;
	cin>>ss>>m>>k;
	if(m>4) m=4;
	mp[m][k]=1;
	for(int i=4;i>=2;i--)
	caozuo(i);
	
	int res=0;
	for(auto [x,y]:mp[1])
		res=(res+dp(x))%mod;
	cout<<res<<endl;
}
signed main()
{
	init();
	IOS;
	int _=1;
	cin>>_;
	while(_--)
		solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 200ms
memory: 73976kb

input:

2
114 1 5
514 2 10

output:

8
10

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 196ms
memory: 74028kb

input:

5
114 1 5
514 2 10
114514 3 7
1919810 2 13
1145141919810114514191981011451419198101145141919810114514191981011451419198101145141919810114514191981011451419198101145141919810 1 79

output:

8
10
16663
504
869252235

result:

wrong answer 3rd lines differ - expected: '12724', found: '16663'