Codeforces Round 1028 Div.1ABD / Div.2CDF
2115A / 2116C - Gellyfish and Flaming Peony 先做出一个 GCD,再将其它数变成 GCD。 看到 5000 考虑 O(n2)\mathcal O(n^{2})O(n2) 的 DP。设 fi,xf_{i,x}fi,x 表示前 iii 个数中至少需要选出几个数才能组合出 GCD 等于 xxx。复杂度 O(nVlogV)\mathcal O(nV\log V)O(nVlogV),V=5000V=5000V=5000,能过。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#include <bits/stdc++.h>using namespace std;using uint = unsigned;using ll = long long;using ull = unsigned long long;using ulll = unsigned __int128;constexpr ll...
The 3rd Universal Cup. Stage 1: St. Petersburg
The 3rd Universal Cup. Stage 1: St. Petersburg
Codeforces Round 1025 (Div. 2) CD
2109C - Hacking Numbers 像是游戏书的思维题 大方向是,用最少步骤得到一个确定的数 yyy,加上 n−yn-yn−y 得到答案。 C1:由于初始 xxx 范围巨大,先用 digit 操作是比较好的。发现两次 digit 操作的结果 x⩽16x \leqslant 16x⩽16,再按二进制拆分,四次就能得到 x=1x=1x=1。总计 6+1=76 + 1 = 76+1=7 次。 12345678910111213141516171819int n;cin >> n;int x;cout << "digit" << endl;cin >> x;cout << "digit" << endl;cin >> x;cout << "add " << -8 << endl;cin >> x;cout << "add " <<...
2025 CCPC 北京市赛暨小米杯全国邀请赛 比赛记录 + 个人题解
The 2024 ICPC Asia Nanjing Regional Contest (The 3rd Universal Cup. Stage 16: Nanjing)
Codeforces Round 1024 (Div. 1)
A - Mex in the Grid 由于不含 0 的网格的 MEX 都是 0,希望更多的网格包括 0,所以 0 放在正中间。数越小就要越靠近中心(严格证明可以看看官方题解),可以构造 12349 8 7 6 10 1 0 5 11 2 3 4 12 13 14 15 1234567891011121314151617181920212223242526272829303132333435363738394041#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int t; cin >> t; while (t--) { int n; cin >> n; vector a(n, vector<int>(n)); int x = (n + 1) / 2 - 1; int y = (n + 1) /...
〔主机註記〕第 66 周主机註記 (May.12 - May.18)
第 66 周主机註記 月曜日 (May.12) 火曜日 (May.13) 水曜日 (May.14) 木曜日 (May.15) 金曜日 (May.16) 土曜日 (May.17) 日曜日 (May.18)
無標題
参考: https://codeforces.com/blog/entry/45223 https://www.cnblogs.com/znpdco/p/18172429 〇 引入 题意 起初有一个数字 000,每一秒钟随机选择一个数字与手上的数字作按位或。选择数字 iii 的概率是 pip_ipi。问期望多少秒后,手上的数字变成 2n−12^n-12n−1。( 洛谷 P3175 [HAOI2015] 按位或) 分析 二进制 nnn 位数字每一位都要变成 1,先分开考虑,求每一位变成 1 的期望时间,然后再合并。但每种情形并不独立,相加后需要减去一些,有点容斥原理的感觉。 考虑 Min-Max 反演的期望形式。 设 xix_{i}xi 表示第 iii 个二进制位变为 1 的期望时间,SSS 是所有 xix_{i}xi 的集合,那么 E[min(S)]\operatorname{E}[\min(S)]E[min(S)] 表示某个集合 TTT 中 有一个 位置变成 1...
〔主机註記〕第 65 周主机註記 (May.5 - May.11)
第 65 周主机註記 月曜日 (May.5) 我驳斥各种心灵鸡汤。 火曜日 (May.6) 有人说,你必须承认绝大多数人的生活都是平凡的。这里的承认一词换成接受也是可以的。 水曜日 (May.7) 木曜日 (May.8) 金曜日 (May.9) 土曜日 (May.10) 日曜日 (May.11)