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;…
题目链接:https://nanti.jisuanke.com/t/41387 题目大意:对于给定序列,求出对于每个位置求出比该数大于m的最靠右的位置. 思路:首先对序列进行离散化,然后对于每个数的下标更新到线段树上,然后对于每个位置的数考虑,二分查找比该数大于m的第一个位置到最右端,查找下标的最大值即可. 代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; int n,m; ],ans[maxn];…