版权声明:转就转吧~~记得声明噢~~ https://blog.csdn.net/Soul_97/article/details/82683537
看例子可以推出来 当n=2时,答案于k的关系为
k > 0 ans = 9 - k
k < 0 ans = 10 + k
k = 0 ans = 9
n每增多一位 答案乘10
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
ll quickpow(ll a,ll b)
{
ll ans = 1;
while(b){
if(b&1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
int main()
{
ll n, k, ans;
cin >> n >> k;
if(k > 0)
ans = 9 - k;
else if(k < 0)
ans = 10 + k;
else
ans = 9;
ll t = quickpow(10, n - 2) % mod;
ll sum = 0;
for(int i = 1;i <= ans;i ++)
sum = (sum + t) % mod;
cout << sum << '\n';
return 0;
}