chore: Add solution for Codeforces problem 1985G
This commit is contained in:
parent
acb7f7a2e4
commit
19e6e66812
33
Codes/1985 G - D-Function/1985G.cpp
Normal file
33
Codes/1985 G - D-Function/1985G.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
#define ll long long
|
||||||
|
#define endl '\n'
|
||||||
|
ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
ll l,r,k;
|
||||||
|
cin>>l>>r>>k;
|
||||||
|
if(k>9)
|
||||||
|
{
|
||||||
|
cout<<0<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ll m=1e9+7;
|
||||||
|
ll ct1=pow(9/k+1,r,m);
|
||||||
|
ll ct2=pow(9/k+1,l,m);
|
||||||
|
ll ans=(ct1-ct2+m)%m;
|
||||||
|
cout<<ans<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||||
|
int TCS = 1;
|
||||||
|
cin >> TCS;
|
||||||
|
for (int TC = 1; TC <= TCS; ++TC)
|
||||||
|
{
|
||||||
|
// cout<<"Case "<<TC<<": ";
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
@ -345,6 +345,7 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
|||||||
| 333 | 1985 D | Manhattan Circle | [Question](https://codeforces.com/problemset/problem/1985/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20D%20-%20Manhattan%20Circle)
|
| 333 | 1985 D | Manhattan Circle | [Question](https://codeforces.com/problemset/problem/1985/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20D%20-%20Manhattan%20Circle)
|
||||||
| 334 | 1985 E | Secret Box | [Question](https://codeforces.com/problemset/problem/1985/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20E%20-%20Secret%20Box)
|
| 334 | 1985 E | Secret Box | [Question](https://codeforces.com/problemset/problem/1985/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20E%20-%20Secret%20Box)
|
||||||
| 335 | 1985 F | Final Boss | [Question](https://codeforces.com/problemset/problem/1985/F) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20F%20-%20Final%20Boss)
|
| 335 | 1985 F | Final Boss | [Question](https://codeforces.com/problemset/problem/1985/F) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20F%20-%20Final%20Boss)
|
||||||
|
| 336 | 1985 G | D-Function | [Question](https://codeforces.com/problemset/problem/1985/G) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20G%20-%20D-Function)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user