这题单用map过不了,太慢了,所以改用unordered_map,对于前面删除的点,把它的父亲改成,后面一位数的父亲,初始化的时候,map里是零,说明它的父亲就是它本身,最后输出答案的时候,输出每一位数的父亲就好了. 下面的程序可能在windows本地编译过不了,头文件放在下面. #include <bits/stdc++.h> using namespace std; unordered_map<int,int>mp; int find(int x) { if (mp[x]==0…
query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be represented as a pair (l ,r )(l,r), you need to find the number of pair(i ,j)(i,j) such that l \le i < j \le rl≤i<j≤r and \min(p_i,p_j) = \gcd(p_i,p_j )…
XKC's basketball team XKC , the captain of the basketball team , is directing a train of nn team members. He makes all members stand in a row , and numbers them 1 \cdots n1⋯n from left to right. The ability of the ii-th person is w_iwi , and if ther…
https://nanti.jisuanke.com/t/41383 解: 斐波那契博弈+中国剩余定理. #include <bits/stdc++.h> using namespace std; ],m[],ans; long long exgcd(long long a,long long b,long long &x,long long &y){ if (!b) {x=,y=;return a;} long long re=exgcd(b,a%b,x,y),tmp=x;…