AC日记——Valued Keys codeforces 801B】的更多相关文章

801B - Valued Keys 思路: 水题... 来,上代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int len; ],s2[],ans[]; int main() { cin>>s1+; cin>>s2+; len=strlen(s1+); ;i<=len;…
Cards Sorting 思路: 线段树: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define INF 0x3f3f3f3f #define maxtree maxn<<2 int n,ai[maxn],val[maxtree],L[ma…
F - Card Game 思路: 题意: 有n张卡片,每张卡片三个值,pi,ci,li: 要求选出几张卡片使得pi之和大于等于给定值: 同时,任意两两ci之和不得为素数: 求选出的li的最小值,如果不能到达给定值则输出-1: 二分+网络流最小割: 代码: #include <bits/stdc++.h> namespace data { #define maxn 105 #define maxque 200005 int val[maxn],mag[maxn],lev[maxn],num,l…
Success Rate 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define ll long long inline void in(ll &now) { ; ') Cget=getchar(); ') { now=now*+Cget-'; Cget=getchar(…
T-Shirt Hunt 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ],ans; bool check(int xx) { if(xx<y) return false; )%; ;j<=;j++) { i=(i*+)%; +i) return true; } retur…
803D - Magazine Ad 思路: 二分答案+贪心: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 1000006 int k,ai[maxn],cnt,num,len,maxlen; char ch[maxn]; bool check(int lit) { ,ti…
D - Broken BST 思路: 二叉搜索树: 它时间很优是因为每次都能把区间缩减为原来的一半: 所以,我们每次都缩减权值区间. 然后判断dis[now]是否在区间中: 代码: #include <map> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005…
797E - Array Queries 思路: 分段处理: 当k小于根号n时记忆化搜索: 否则暴力: 来,上代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 ],size; inline void in(int &am…
803C - Maximal GCD 思路: 最大的公约数是n的因数: 然后看范围k<=10^10; 单是答案都会超时: 但是,仔细读题会发现,n必须不小于k*(k+1)/2: 所以,当k不小于10^5时直接-1就好: 我们可以构造出gcd为1的序列为 1,2,3,4……n-k+1: 然后一个个枚举n的因子p: 1*p,2*p,3*p……(n-k+1)*p: 当枚举的p使得序列不满足于严格递增时,结束,输出合法答案: 来,上代码: #include <cmath> #include &l…
801A - Vicious Keyboard 思路: 水题: 来,上代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int len,ans; ]; int check() { ; ;i<len;i++) { ]=='K') res++; } return res; } int main() {…