QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712727#7996. 报数 IVszy10010WA 70ms146208kbC++231.9kb2024-11-05 16:49:252024-11-05 16:49:25

Judging History

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

  • [2024-11-05 16:49:25]
  • 评测
  • 测评结果:WA
  • 用时:70ms
  • 内存:146208kb
  • [2024-11-05 16:49:25]
  • 提交

answer

#include <map>
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define pb emplace_back
#define pp pop_back()
#define int long long
#define laile cout<<"laile"<<endl
#define lowbit(x) ((x)&(-x))
#define double long double
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sd(x) scanf("%Lf",&x)
#define sdd(x,y) scanf("%Lf %Lf",&x,&y)
#define _for(i,n) for(int i=0;i<(n);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _pre(i,a,b) for(int i=(a);i>=(b);--i)
#define all(x) (x).begin(), (x).end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
const int N=1e6+10,INF=4e18;
int n,m;
int g[10010][5];
int deal(int i)
{
	int res=0;
	while(i)
	{
		res+=i%10;
		i/=10;
	}
	return res;
}
void init()
{
	for(int i=1;i<=9000;i++)
	{
		int x=i;
		g[i][0]=x;
		x=deal(x),g[i][1]=x;
		x=deal(x),g[i][2]=x;
		x=deal(x),g[i][3]=x;
		x=deal(x),g[i][4]=x;
	}
	return ;
}
int f[1010][9010][2];//前i位,值为j,贴上界状态为k的数字的个数
void solve()
{
	string s;
	int k;
	cin>>s>>k>>m;
	n=s.size();
	s=" "+s;
	memset(f,0,sizeof(f));
	f[0][0][1]=1;
	_rep(i,1,n)
	{
		int x=s[i]-'0';
		_rep(j,0,9000)
		{
			_rep(k,0,min(9ll,j))
			{
				f[i][j][0]+=f[i-1][j-k][0];
				if(k<x)f[i][j][0]+=f[i-1][j-k][1];
				else if(k==x)f[i][j][1]+=f[i-1][j-k][1];
			}
		}
	}
	k--;
	k=min(k,4ll);
	ULL res=0;
	_rep(j,0,9000)
	{
		if(g[j][k]!=m)continue;
		res+=f[n][j][0]+f[n][j][1];
	}
	cout<<res<<'\n';
	return ;
}
signed main()
{
	IOS;
	int T=1;
	init();
    cin>>T;
	while(T--)
		solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 19ms
memory: 146164kb

input:

2
114 1 5
514 2 10

output:

8
10

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 70ms
memory: 146208kb

input:

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

output:

8
10
12724
504
16034733696774178310

result:

wrong answer 5th lines differ - expected: '481046284', found: '16034733696774178310'