上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页
摘要: //求全排列 next_permutation(begin,end)/*next_permutation(start,end),和prev_permutation(start,end)。这两个函数作用是一样的,区别就在于前者求的是当前排列的下一个排列,后一个求的是当前排列的上一个排列。至于这里的“前 阅读全文
posted @ 2022-02-26 23:23 fengzlj 阅读(42) 评论(0) 推荐(0)
摘要: 离散化 离散化就是对应,把太分散的数字通过离散化对应到一个连续的数组上,然后以方便存储 void discreate(){ sort(a+1,a+n+1); for(int i=1;i<=n;i++){ if(i==1||a[i]!=a[i-1]) b[++m]=a[i]; } return ;}i 阅读全文
posted @ 2022-02-26 23:22 fengzlj 阅读(36) 评论(0) 推荐(0)
摘要: 逆序对 求任意两个区间之间所形成的逆序对的个数 LL calc(Node x,Node y){ LL l=max(x.l,y.l); if(l>x.r) return 0; LL r=min(x.r,y.r); LL ans=(l-y.l+r-y.l)*(r-l+1)/2%mod; ans=(ans 阅读全文
posted @ 2022-02-26 23:21 fengzlj 阅读(158) 评论(0) 推荐(0)
摘要: ST表 # include <bits/stdc++.h>using namespace std;​const int MAXN=1e5+100;int a[MAXN];int f[MAXN][20];int len[MAXN];int n,m;void ST_len(){ for(int i=1; 阅读全文
posted @ 2022-02-26 23:21 fengzlj 阅读(49) 评论(0) 推荐(0)
摘要: priority_queue #include <iostream>#include <queue>using namespace std;​//方法1struct tmp1 //运算符重载<{ int x; tmp1(int a) {x = a;} bool operator<(const tmp 阅读全文
posted @ 2022-02-26 23:20 fengzlj 阅读(153) 评论(0) 推荐(0)
摘要: 快读 inline LL read(){ LL X=0,w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); re 阅读全文
posted @ 2022-02-26 23:20 fengzlj 阅读(17) 评论(0) 推荐(0)
摘要: 差分、前缀和和组合数 1、 所加的如果式组合数的话,可以通过多次前缀和求得,进而用差分解决区间加的问题。 # include <bits/stdc++.h>using namespace std;​typedef long long LL;const int MAXN=1e5+100;const L 阅读全文
posted @ 2022-02-26 23:20 fengzlj 阅读(182) 评论(0) 推荐(0)
摘要: 数论分块 n/i 有2*sqrt(n)种情况 2.对于n/i 有分块区间 [ l , r ] , 其中 r = n / ( n / l ) for(int l=1,r;l<=n;l=r+1){ LL a=n/l;//当前区间中的数 r=n/(n/l);//区间的右端点 //do something} 阅读全文
posted @ 2022-02-26 23:19 fengzlj 阅读(32) 评论(0) 推荐(0)
摘要: lower_bound( )和upper_bound( ) 都是利用二分查找的方法在一个排好序的数组中进行查找的。 在从小到大的排序数组中, lower_bound( begin,end,num):从数组的begin位置到end-1位置二分查找第一个大于或等于num的数字,找到返回该数字的地址,不存 阅读全文
posted @ 2022-02-26 23:19 fengzlj 阅读(35) 评论(0) 推荐(0)
摘要: Minimal Power of Prime 哭死,以为是米勒拉宾和扑拉德诺,结果是一个思维题,对不起队友啊,优化五小时,优化不出来 其实就是先对一个数,把1e4以前的质数因子全部先找一遍,然后再对大于1e4的因子,再查询,最大的指数是4,所以只有可能是4,3,2,1次 # include <bit 阅读全文
posted @ 2022-02-26 23:18 fengzlj 阅读(25) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页