[题解] 鲜活的水题..我们把数列换成k进制的,发现数列是001,010,011,100,101,110,111...,而第m项用k进制表示的01串刚好就是m的二进制的01串.于是我们预处理k的幂,把n化成2进制的,在用这个01串求数列第n项即可. #include<cstdio> #include<algorithm> #define rg register #define N 50 #define LL long long using namespace std; ],tot;…
洛谷P2661 信息传递 最小环求解采用并查集求最小环. 只适用于本题的情况.对于新加可以使得两个子树合并的边,总有其中一点为其中一棵子树的根. 复杂度 \(O(n)\) . #include<bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 200005; int f[maxn], dist[maxn]; int n, to, ans; int father(int x) { if…