QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393955#7996. 报数 IVOOBMABTRAMS#RE 1ms3868kbC++231.1kb2024-04-19 17:45:382024-04-19 17:45:39

Judging History

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

  • [2024-04-19 17:45:39]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3868kb
  • [2024-04-19 17:45:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const int N=9013;
const int mod=1e9+7;
int f[9013][5];
int cnt[1013][9013];
void solve(){
    string s;
    cin>>s;
    int k,m;
    cin>>k>>m;
    k--;
    if(k>5)k=4;
    int sum=0;
    vector<int>v;
    ll ans=0;
    int n=s.size();
    for(int i=0;i<N;i++)if(f[i][k]==m)v.push_back(i);
    for(int j=0;j<=n;j++)for(int i=0;i<=n*9;i++)cnt[i][j]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i]-'0';j++)cnt[i+1][sum+j]++;
        sum+=s[i]-'0';
    }
    for(int i=1;i<n;i++)for(int j=0;j<=i*9;j++)if(cnt[i][j])for(int k=0;k<=9;k++){
        (cnt[i+1][j+k]+=cnt[i][j]);
        if(cnt[i+1][j+k]>=mod)cnt[i+1][j+k]-=mod;
    }
    cnt[n][sum]++;
    for(auto x:v){
        (ans+=cnt[n][x])%=mod;
    }
    cout<<ans<<'\n';
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    for(int i=1;i<N;i++)f[i][1]=f[i/10][1]+i%10,f[i][0]=i;
    for(int j=2;j<5;j++)for(int i=1;i<N;i++)f[i][j]=f[f[i][j-1]][j-1];
    int T=1;
    cin>>T;
    while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3868kb

input:

2
114 1 5
514 2 10

output:

8
10

result:

ok 2 lines

Test #2:

score: -100
Runtime Error

input:

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

output:


result: