QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712731 | #7996. 报数 IV | szy10010 | WA | 0ms | 6168kb | C++23 | 2.1kb | 2024-11-05 16:50:24 | 2024-11-05 16:50:25 |
Judging History
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,P=1e9+7;
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;
f[0][0][1]=1;
_rep(i,1,n)
{
int x=s[i]-'0';
_rep(j,0,9000)
{
f[i][j][1]=f[i][1][0]=0;
_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];
f[i][j][0]%=P;
f[i][j][1]%=P;
}
// cout<<i<<" "<<j<<" "<<f[i][j][0]<<endl;
}
}
k--;
k=min(k,4ll);
ULL res=0;
_rep(j,0,9000)
{
if(g[j][k]!=m)continue;
// cout<<j<<" "<<f[n][j][0]<<" "<<f[n][j][1]<<endl;
res+=f[n][j][0]+f[n][j][1];
res%=P;
}
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: 0
Wrong Answer
time: 0ms
memory: 6168kb
input:
2 114 1 5 514 2 10
output:
6 9
result:
wrong answer 1st lines differ - expected: '8', found: '6'