思维题,推出公式用等比数列求和做一下。
1 #define IO std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 2 #define bug2(x,y) cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl 3 #define bug(x) cout<<#x<<" is "<<x<<endl; 4 #include<bits/stdc++.h> 5 #define eb emplace_back 6 typedef long long ll; 7 using namespace std; 8 const ll mod = 1e9+7; 9 10 ll fp(ll x, ll y){ 11 ll res = 1; 12 while(y){ 13 if(y&1) res = res * x % mod; 14 x = x * x % mod; 15 y >>= 1; 16 } 17 return res; 18 } 19 20 void solve(){ 21 22 ll l, r, k, x; 23 24 cin >> l >> r >> k; 25 26 if(k >= 10) cout << 0 << endl; 27 else{ 28 29 x = 9 / k + 1; 30 31 ll res = fp(x, r - l); 32 33 ll a1 = fp(x, l); 34 35 res = (a1 * ((res - 1 + mod) % mod) % mod) * fp(x - 1, mod - 2) % mod; 36 37 res = res * (x - 1) % mod; 38 39 cout << res <<endl; 40 41 } 42 43 } 44 45 int main(){ 46 47 IO; 48 int T; 49 cin >> T; 50 while(T--) { 51 solve(); 52 } 53 54 55 }
标签:Function,cout,res,ll,952,Codeforces,mod,define From: https://www.cnblogs.com/ccsu-kid/p/18251225