摘要: /* 维护的是前k个中最大的数和它的下标 最大数为front(); */ class Deque{ public: deque<int>a; deque<int>id; int k; bool empty(){ return a.empty(); } void pop(int i){//弹首 whi 阅读全文
posted @ 2020-11-14 16:56 yesuweiYYYY 阅读(78) 评论(0) 推荐(0) 编辑
摘要: //CF1443 E /* 算法:康托展开 给定一个全排列,求它是第几小的全排列。 如 4 2 1 3。 解: int k=0; 对于 4 它后面有三个数比他小: k+=3 * (3!) 比它小的个数 * 排列数目,因为若前面的数保持不懂,仅仅统计当前数和它后面的数,1***,2***,3***均比 阅读全文
posted @ 2020-11-05 18:44 yesuweiYYYY 阅读(93) 评论(0) 推荐(0) 编辑
摘要: //找最长回文字串 #include <bits/stdc++.h> using namespace std; const int N=2e7+2e6+10; void in(int &x){ x=0;char c=getchar(); int y=1; while(c<'0'||c>'9'){if 阅读全文
posted @ 2020-11-02 17:41 yesuweiYYYY 阅读(53) 评论(0) 推荐(0) 编辑
摘要: ``` /*例题:Description:有n个数字,数字k,m个查询。每次查询的格式是L,r,求L~r(左右包含)这个区间内数字的出现次数刚好是k的数字种数。范围:n<=30000,k<=n,m<=30000,1<=L<r<=n,数列中元素大小<=n。输入n,k,m,然后n个元素,然后m行查询,对 阅读全文
posted @ 2020-11-02 00:26 yesuweiYYYY 阅读(91) 评论(0) 推荐(0) 编辑
摘要: class Deque{public: int a[maxn]; int pl=1,pr=0;}Deq;int a[maxn];int n,k;void solve(){ Deq.pl=1;Deq.pr=0; for(int i=1;i<=n;i++){ while(Deq.pr>=Deq.pl&& 阅读全文
posted @ 2020-10-19 16:56 yesuweiYYYY 阅读(99) 评论(0) 推荐(0) 编辑
摘要: map<string,ll>mapp;map<string,ll>::iterator it;for(it=mapp.begin();it!=mapp.end();it++){ if(it->second>0){ t=it->first; }} 阅读全文
posted @ 2020-10-15 15:23 yesuweiYYYY 阅读(149) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> #define N 39989 using namespace std; const int mod=39989; const int modd=1e9; struct Seg { double k,b; Seg(){} Seg(int x0,int 阅读全文
posted @ 2020-10-13 20:07 yesuweiYYYY 阅读(85) 评论(0) 推荐(0) 编辑
摘要: ``` /* * 辛普森积分公式:sum(l,r)=( f(l)+f(r)+4*f((l+r)/2) ) * (r-l) / 6 * 解: 对 f 函数在 (l,r) 的积分可以用 以上函数拟合 * * 欲对 (l,r) 的一段函数积分并给出了精度要求 * 可以对此段区间,递归使用上述公式(以设置的 阅读全文
posted @ 2020-10-13 16:36 yesuweiYYYY 阅读(393) 评论(0) 推荐(0) 编辑
摘要: bool isP[Maxn]; long long Prime[Maxn],cnt=0; void GetPrime(){ for(long long i=1;i<Maxn;i++) isP[i]=1; isP[1]=0; for(long long i=2;i<Maxn;i++){ if(isP[ 阅读全文
posted @ 2020-10-13 16:33 yesuweiYYYY 阅读(68) 评论(0) 推荐(0) 编辑
摘要: vector<int>v; void init(){ sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); } int getid(int x){ return lower_bound(v.begin(),v.end 阅读全文
posted @ 2020-10-13 16:13 yesuweiYYYY 阅读(65) 评论(0) 推荐(0) 编辑