摘要:
struct Tree { int n, d = 0; //顶点,直径,树中心 //自顶向下u到其叶子结点最远距离d1,次长距离d2(与最长路径无公共边) //p1,p2表示结点u向下更新时是由哪个结点更新来的 //up表示结点u向上到祖宗结点的最远距离 vector<int> d1, d2, p1 阅读全文
摘要:
jiangly的板子 // 取模机 // using i64 = long long; template<class T> constexpr T power(T a, i64 b) { T res {1}; for (; b; b /= 2, a *= a) { if (b % 2) { res 阅读全文
摘要:
AtCoder Beginner Contest 363 前言 只出了三题,被 d 卡住了,事实上 e 题应该对我而言更简单,没及时换题。 A - Piling Up (atcoder.jp) 思路 代码 #include<bits/stdc++.h> using namespace std; us 阅读全文
摘要:
2024牛客暑期多校训练营2 E-GCD VS XOR_2024牛客暑期多校训练营2 (nowcoder.com) 题意 给定 x,构造 y < x 使得 gcd(x, y) = x ⊕ y 思路 取 x − lowbit(x) 即可,如果 x 是 2 的整数次幂则无解。 代码 #include<b 阅读全文