摘要: #include<iostream> #include<stdio.h> #include<cstring> using namespace std; struct ss{ int next,to; };ss data[200010]; const int inf=1e9+7; int n,q,ti 阅读全文
posted @ 2020-03-31 15:59 慎独191812 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 1 #include<cstdio> 2 using namespace std; 3 #define MAXN 111111 4 int stack[MAXN]; 5 int l[MAXN],r[MAXN]; 6 long long a[MAXN],s[MAXN]; 7 int main(){ 8 阅读全文
posted @ 2020-03-06 15:24 慎独191812 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 1 #include <bits/stdc++.h> 2 #define maxn 200010 3 using namespace std; 4 int ent,n,m,l,r,k; 5 int L[maxn],R[maxn],sum[maxn];//×ó¶ù×Ó ÓÒ¶ù×Ó ½ÚµãÖµ 6 阅读全文
posted @ 2020-02-02 16:34 慎独191812 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 1 #include <bits/stdc++.h> 2 #define ll long long 3 static const int INFTY=2147483647; 4 const int maxm=500010; 5 using namespace std; 6 struct edge{ 阅读全文
posted @ 2020-02-02 14:13 慎独191812 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 同余对于一般除法不封闭,因此有乘法逆元 1.费马小定理 a^(p-1)=1 mod p,p为素数 故a mod p的逆元为a^(p-1),快速幂即可 1 int pow( int n, int k) { 2 long long ans = 1; 3 while(k) 4 { 5 if(k&1)ans 阅读全文
posted @ 2020-01-20 16:21 慎独191812 阅读(90) 评论(0) 推荐(0) 编辑
摘要: A.Shuffle Hashing 题意:给定s1,s2两个字符串。问s2中是否有s1不计顺序的字串。 题解:sort就完事了,比较一下就好。 贴dalao代码 1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() { 4 in 阅读全文
posted @ 2019-12-21 12:12 慎独191812 阅读(232) 评论(0) 推荐(0) 编辑
摘要: A.Math Problem(CF 1262 A) 题意:给一些区间,求构造最短的区间长度于所给区间有交集。 题解:贪心,取左端点最大,右端点最小,作差以后和0比较取最大值。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int t; 4 in 阅读全文
posted @ 2019-11-25 15:01 慎独191812 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 官方题解; (有时候不知怎么打不开cf,搬过来方便看) 1253A - Один подъем If we set di=bi−aidi=bi−ai, we have to check that dd has the following form: [0,0,…,0,k,k,…,k,0,0,…,0] 阅读全文
posted @ 2019-11-17 20:52 慎独191812 阅读(309) 评论(0) 推荐(0) 编辑
摘要: A - Two Rival Students 题意:共n个人排一排,两个人,位于a,b,相邻位置交换至多x次,求max abs(a-b)。 题解:贪心,能往左就往左,能往右就往右,超过x次就只算x次就行了。 1 #include <iostream> 2 #include<algorithm> 3 阅读全文
posted @ 2019-11-14 16:03 慎独191812 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 判断素数:对于n,分别枚举1-sqrt(n)。 最朴素的素数筛——埃拉托斯特尼筛法(Sieve of Eratosthenes) 1 int primes[MAXN],ent=0; 2 bool isPrime[MAXN]; 3 void getPrime() 4 { 5 memset(isPrim 阅读全文
posted @ 2019-11-10 16:32 慎独191812 阅读(267) 评论(0) 推荐(0) 编辑

Contact with me