QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#713474#7996. 报数 IVsdmrlhWA 297ms74124kbC++141.5kb2024-11-05 19:32:582024-11-05 19:32:59

Judging History

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

  • [2024-11-05 19:32:59]
  • 评测
  • 测评结果:WA
  • 用时:297ms
  • 内存:74124kb
  • [2024-11-05 19:32:58]
  • 提交

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=1;i<=1000;i++)
		for(int j=0;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: 232ms
memory: 74124kb

input:

2
114 1 5
514 2 10

output:

8
10

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 237ms
memory: 74116kb

input:

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

output:

8
10
12724
504
481046284

result:

ok 5 lines

Test #3:

score: -100
Wrong Answer
time: 297ms
memory: 74004kb

input:

5
3134666912140933323880320519044791121794814671711104987304374190280064994554822259889216567113228716903875026053927191961850586115167336109747673868148288830282192461669674173201533887392623483710043038941036243583011049049915834937139438028987629569618561762595613799223807979488245056374812076511...

output:

464777424
613343513
0
500149787
932367667

result:

wrong answer 1st lines differ - expected: '0', found: '464777424'