QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#352287 | #7996. 报数 IV | Kevin5307 | WA | 8ms | 74248kb | C++20 | 890b | 2024-03-13 08:04:53 | 2024-03-13 08:04:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[1005][9005][2];
void upd(int &a,int b)
{
a+=b;
if(a>=mod)
a-=mod;
}
int d(int x,int k)
{
while(k&&x>=10)
{
int tmp=x;
x=0;
while(tmp)
{
x+=tmp%10;
tmp/=10;
}
k--;
}
return x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
string n;
int k,m;
cin>>n>>k>>m;
memset(dp,0,sizeof(dp));
dp[0][0][1]=1;
for(int i=0;i<n.length();i++)
for(int j=0;j<=9*i;j++)
for(int k=0;k<2;k++)
for(int x=0;x<10;x++)
if(x<=(n[i]^48)||!k)
upd(dp[i+1][j+x][k&&(x==n[i]^48)],dp[i][j][k]);
int ans=0;
for(int j=0;j<=n.length()*9;j++)
if(d(j,k-1)==m)
{
upd(ans,dp[n.length()][j][0]);
upd(ans,dp[n.length()][j][1]);
}
cout<<ans<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 74248kb
input:
2 114 1 5 514 2 10
output:
3 0
result:
wrong answer 1st lines differ - expected: '8', found: '3'