题目大意:数字的每位每次加一
动态规划预处理:
#include <bits/stdc++.h>
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define fep(i,a,b) for(int i=b;i>=a;--i)
#define mem(x,y) memset(x,y,sizeof(x))
#define inf 2147483647
const int mod = 1e9+7;
const int N = 2e5;
using namespace std;
ll dp[N+10];
void solve()
{
int n, m;
cin >> n >> m;
ll ans=0;
while(n)
{
int x=10-n%10;
if(m<x) ans=(ans+1)%mod;
else ans=(ans+dp[m-x])%mod;
n /= 10;
}
printf("%lld\n",ans);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
for (int i = 0; i <= 8; i++) dp[i] = 2;
dp[9] = 3;
for (int i = 10; i <= 200010; i++)
{
dp[i] = (dp[i - 9] + dp[i - 10]) % mod;
}
int T; cin >> T;
while (T--)
solve();
return 0;
}
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define fep(i,a,b) for(int i=b;i>=a;--i)
#define mem(x,y) memset(x,y,sizeof(x))
#define inf 2147483647
const int mod = 1e9+7;
const int N = 2e5;
using namespace std;
vector<int>v;
ll sum[N+10], dp[N+10][15];
void fun()
{
dp[0][1]=1;dp[0][0]=1;sum[0]=2;
for(int i=1;i<N;++i)
for(int j=0;j<=9;++j)
{
if(j) dp[i][j]=dp[i-1][j-1];
if(j==0||j==1) dp[i][j]=(dp[i][j]+dp[i-1][9])%mod;
sum[i]=(sum[i]+dp[i][j])%mod;
}
}
void solve()
{
int n, m;
scanf("%d%d",&n,&m);
ll ans=0;
while(n>0)
{
int x=10-n%10;
if(m<x) ans=(ans+1)%mod;
else ans=(ans+sum[m-x])%mod;
n /= 10;
}
printf("%lld\n",ans);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
fun();
int T;
scanf("%d", &T);
while (T--)
solve();
return 0;
}