首页 > 其他分享 >Codeforces Round #818 (Div. 2) A Madoka and Strange Thoughts

Codeforces Round #818 (Div. 2) A Madoka and Strange Thoughts

时间:2022-09-03 01:11:53浏览次数:78  
标签:Madoka cin int ak Codeforces bk 818 include

Madoka and Strange Thoughts

唯一分解定理

\[gcd(a, b) = p_1^{min(ak_1, bk_1)} * p_2^{min(ak_2, bk_2)}... \]

\[lcm(a, b) = p_1^{max(ak_1, bk_1)} * p_2^{max(ak_2, bk_2)}... \]

根据上面两个式子就可以知道 \(\frac{lcm(a,b)}{gcd(a,b)}\) 其实就是质因数最大最小次幂相差多少

因为题目说 \(\frac{lcm(a,b)}{gcd(a,b)} \le 3\),因此 \(a\) 和 \(b\) 之间就只能满足倍数为 \(1\)、\(2\)、\(3\) 倍

下次见到要多想想上面两个式子

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <deque>
#include <stack>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
const ll maxn = 2e5 + 10;
const ll inf = 1e17 + 10;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int ans = n / 3 + n / 2;
        ans *= 2;
        ans += n;
        cout << ans << "\n";
    }
    return 0;
}

标签:Madoka,cin,int,ak,Codeforces,bk,818,include
From: https://www.cnblogs.com/dgsvygd/p/16651802.html

相关文章

  • *Codeforces Round #651 (Div. 2) C. Number Game(博弈论)
    https://codeforces.com/contest/1370/problem/CAshishgup和FastestFinger玩游戏。他们从数字n开始,轮流玩。在每个回合中,玩家可以进行以下任意一个动作:将n除以任何大......
  • Educational Codeforces Round 123 D
    D.CrossColoring很容易想到的就是分成几个块有几个就是k多少次幂但是显然暴力的做法是n2的我们考虑如何优化我们考虑对每一行这个x[i]能成立的条件是啥那就是y[i]......
  • Educational Codeforces Round 123 E
    E.ExpandthePath我们画出一个合法的一般性的来研究比如RDRDR我们可以将其任意一个往下往右延长但是这个图形获得的面积是不规则的但是我们知道合法的序列肯定是......
  • Codeforces Round #814 (Div. 2)
    Preface关于军训……它死了第一次感觉到疫情的好处,就是不知道训了一半给不给学分,要不要补训一直打隔膜颓废也不是办法,因此来写写题(才不是因为路由器没到舍不得用流量更......
  • Educational Codeforces Round 134 (Rated for Div. 2) D Maximum AND
    MaximumAND贪心从高位开始,尽可能地让\(a\)中该位为\(0\)的和\(b\)中该位为\(1\)的配对在一起,换句话说,可以让\(a\)由小到大排序,\(b\)由大到小排序如果当......
  • codeforces极简题解
    CF1713F利用lucas定理,\(b_S\)表示下标\(T\)与\(S\)无交的\(a_T\)的异或,由于部分\(b_S\)未知,不能直接iFWT。回顾容斥:\([S=\emptyset]=\sum_{T\subseteqS}(-1)^|T|\),\([n=0......
  • Codeforces Round #773 E
    AnonymityIsImportant我们最开始会想到用三个状态表示其实并不用我们只需要用0表示这个人没病1表示不确定有病(这样我们就可以用set来做了)要是一个区间给了有病我们......
  • Educational Codeforces Round 134 (Rated for Div. 2)
    DMaxiumAnd贪心,优先满足高位,每次判断是否能够满足这一位答案为1,如果能则更新答案,这样显然是优的EPrefixFunction模仿求前缀函数的算法,先预处理求出\(|S|\)的前缀函......
  • Educational Codeforces Round 134 (Rated for Div. 2)
    EducationalCodeforcesRound134(RatedforDiv.2)目录EducationalCodeforcesRound134(RatedforDiv.2)D.MaximumANDE.PrefixFunctionQueriesD.Maximum......
  • Codeforces Round #606(B-D)
     Dashboard-CodeforcesRound#606(Div.2,basedonTechnocup2020EliminationRound4)-CodeforcesB.MakeThemOdd题意:一个数组,每次选择一个数,将数组中的......