化简 题给公式有
an- a1 ==k
可行解则是
a1 .... an
枚举a1
可得an的范围
中间段的可能取值,显而易见可通过快速幂得出
累加a1的所有可行解即可
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define qios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define inf INT_MAX #define il inline const ll mod=1e9+7; ll qpow(ll a, ll b) { ll res=1; while (b) { if (b&1) res=(res*a)%mod; a=(a*a)%mod; b>>=1; } return res; } signed main() { ll n, k; cin>>n>>k; ll ans=0; for (int i=1;i<=9;++i) if (i+k<=9 and i+k>=0) ans=(ans+qpow(10, n-2)%mod)%mod; std::cout << ans << std::endl; return 0; }