QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#713504#7996. 报数 IVsdmrlhWA 293ms74096kbC++141.4kb2024-11-05 19:38:562024-11-05 19:38:56

Judging History

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

  • [2024-11-05 19:38:56]
  • 评测
  • 测评结果:WA
  • 用时:293ms
  • 内存:74096kb
  • [2024-11-05 19:38:56]
  • 提交

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<=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;
			}
}

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=(sum+1)%mod;
	}
	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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 229ms
memory: 74068kb

input:

2
114 1 5
514 2 10

output:

8
10

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 213ms
memory: 74096kb

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: 293ms
memory: 74080kb

input:

5
3134666912140933323880320519044791121794814671711104987304374190280064994554822259889216567113228716903875026053927191961850586115167336109747673868148288830282192461669674173201533887392623483710043038941036243583011049049915834937139438028987629569618561762595613799223807979488245056374812076511...

output:

464777424
613343513
0
500149787
932367667

result:

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