首页 > 其他分享 >Codeforces Round 952 (Div. 4) G. D-Function(思维)

Codeforces Round 952 (Div. 4) G. D-Function(思维)

时间:2024-06-16 20:54:37浏览次数:11  
标签:Function cout res ll 952 Codeforces mod define

Problem - G - Codeforces

思维题,推出公式用等比数列求和做一下。

 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

相关文章

  • CodeForces 1935A
    题目链接:EntertainmentinMAC思路代码#include<bits/stdc++.h>usingnamespacestd;#definelllonglongconstintN=1e5+10;voidsolve(){lln;strings;cin>>n>>s;intl=0,len=s.size();while(s[l]==s[......
  • Codeforces Round 952 (Div. 4)
    A.CreatingWordstimelimitpertest:1secondmemorylimitpertest:256megabytesinput:standardinputoutput:standardoutputMatthewisgiventwostringsa......
  • Codeforces Round 947 (Div. 1 + Div. 2)
    发现今天做不了一点题,遂来补以前的比赛。B.378QAQandMocha'sArray秒了。排序,取最小的数记为\(x\),再取最小的无法被\(x\)整除的数记为\(y\),如果仍然存在无法被\(y\)整除的数,则无解。C.ChamoandMocha'sArray容易想到一个结论:如果一个数比它左边或右边的数小,那么......
  • Codeforces Round 836题解(A、B、C)
    A.SSeeeeiinnggDDoouubbllee直接将原字符串翻转一下拼到原字符串的后面就构成了回文串。strings;voidsolve(){cin>>s;cout<<s;reverse(s.begin(),s.end());cout<<s<<'\n';}B.XOR=Average分\(n\)的奇偶性考虑,若\(n\)为奇数,我们可以......
  • JDK8新特性【接口新特征、lambda语法、Supplier、Consumer、Function、Predicate】
    目录一、关于接口的新特性1.1jdk1.8之前的接口重要特性1.2JDK8以后代码演示1.3总结通过代码演示发现作用二、Lambda表达式[重点]2.1将匿名内部类写法改写为lambda写法2.2语法特点能够写成lambda形式的的前提语法特征代码演示深入理解lambda2.3总结三、函数......
  • Codeforces Round 952 (Div. 4) 题解分享
    A.CreatingWords思路模拟,交换输出即可codeinlinevoidsolve(){stringa,b;cin>>a>>b;swap(a[0],b[0]);cout<<a<<''<<b<<endl; return;}B.MaximumMultipleSum思路暴力枚举数学不会()codein......
  • G. D-Function
    原题链接题解先不考虑k的限制,而是考虑对于任意一个数,存不存在一个k使得题目所给等式成立当\(n·k\)没有进位时,等式一定成立(赛时也许想到这就够了)假如有进位呢?对于任何一个位数大于1的数,必有\(D(n)\ltn\)(想想十进制是怎么表示数的)而对于位数为1的数,有\(D(n)=n\)所......
  • Codeforces Round 952 (Div. 4)
    A读入两个字符串,交换第一位即可。B题意给定整数\(n\),求一个整数\(x\),满足:\(2\leqx\leqn\)。\(\displaystyle\sum\limits_{i=1}^ki\cdotx\)最大,其中\(k\)为满足\(kx\leqn\)最大的正整数。思路赛时思路可以直接枚举\(x\)的所有情况,暴力计算答案。......
  • Codeforces Round 952 (Div. 4)
    link赛时过了ABCD,rank15270,我嘞个豆啊,虽然菜成shi了,但是打得很开心,凌晨一点多还兴奋得不得了。就是网络好差,比赛开始好几分钟了还被关在外边。A-CreatingWordsB-MaximumMultipleSum签到题,略C-GoodPrefixes想到用前缀和,一开始写成每次往后一位后缀,只对最后一......
  • Codeforces Round 952 (Div. 4)
    A.CreatingWordsvoidsolve(){ stringa,b; cin>>a>>b; swap(a[0],b[0]); cout<<a<<''<<b<<'\n';}B.MaximumMultipleSum总结:作为一个等差数列,快速的找到最高次系数,以及快速求和..C=n/x,sum=(c*x+......