从2e5-1依次枚举每个数作为主显卡,然后分段求比它大的数的个数,这里的复杂度是调和级数ln2e5,即埃氏筛的复杂度.. #include<bits/stdc++.h> using namespace std; #define ll long long #define N 200005 int cnt[N],n; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 ll num[N<<]; void updat…
我们一般写的埃氏筛消耗的时间都是欧拉筛的三倍,但是欧拉筛并不好想(对于我这种蒟蒻) 虽然 -- 我 -- 也可以背过模板,但是写个不会的欧拉筛不如写个简单易懂的埃氏筛 于是就有了优化 这个优化还是比较厉害的,能把埃氏筛的消耗的时间提的跟欧拉筛差不多 以下内容需要先学会埃氏筛 学会的埃氏筛就明白它的原理了吧 #include<bits/stdc++.h> using namespace std; int n, m ,Is_p[10000001]; int main() { cin >>…
Recently, the bear started studying data structures and faced the following problem. You are given a sequence of integers x1, x2, ..., xn of length n and m queries, each of them is characterized by two integers li, ri. Let's introduce f(p) to represe…
Nico Number Time Limit: 2 Seconds Memory Limit: 262144 KB Kousaka Honoka and Minami Kotori are playing a game about a secret of Yazawa Nico. When the game starts, Kousaka Honoka will give Minami Kotori an array A of N non-negative integers. Ther…