![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
mzAGGy
(⌒-⌒; )
展开
-
Codeforces Round #736 div2
CONTEST LINKA.Gregor and Cryptography题意:给你一个质数p,让你找到两个大于等于2且小于p的数a和b,满足p%a==p%b思路:1.大于2的质数都是奇数,所以对于任意质数,p%2==1永恒成立2.还有什么是永真的呢?显然p%(p-1)==1代码:#include<bits/stdc++.h>using namespace std;void sol(){ int n; cin>>n; cout<<2<&l原创 2021-08-02 12:03:16 · 114 阅读 · 0 评论 -
Codeforces Round 721 Div2
比赛链接A.And Then There Were K#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;typedef long long ll;int main() { int t; cin >> t; while (t--) { ll a; cin >> a; i原创 2021-05-21 00:26:45 · 136 阅读 · 2 评论 -
Educational Codeforces Round 109
蒟蒻只做出了两道签到题…剩下的题待补。比赛链接A.Potion Making#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>using namespace std;typedef long long ll;int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b);}int mai原创 2021-05-16 20:44:44 · 201 阅读 · 2 评论 -
Codeforces 1512D Corrupted Array
题目链接思路先升序排序b,显然有两种情况可以找到序列a。 - 前n项之和等于第n+1项,也就是要扔掉第n+2项 - (前n+1项之和)-(某一项)==第n+2项,也就是要扔掉那某一项关于第二种情况,用rtmp记录(前n+1项之和-第n+2项)的值显然要删的那个项的值就是rtmpAC代码#include <iostream>#include <algorithm>#include <cstring>#include <string>.原创 2021-05-13 22:03:36 · 125 阅读 · 0 评论 -
Codeforces Round #712 (Div. 2) B. Flip the Bits
题目链接在此题目大意:给出a、b两个由0和1组成的字符串现在你可以选择一段0和1数量相等的前缀,将其所有0换成1,所有1换成0你可以操作无数次你只需要判断a能否经过若干次操作变成b思路这题我一开始是想直接模拟的,就是从后往前遍历a,遇到a[i]!=b[i]时,若可以反转,就反转一次,否则直接输出NO,写到一半发觉复杂度不对劲…Ctrl+A+Backspace删代码可真爽…正解:用数组c记录字符串a各位置0和1的相对数量(例如c[i]==-1表示:从开头到下标i的这段前缀0比1原创 2021-05-13 20:40:42 · 62 阅读 · 0 评论 -
Codefores round #719 div3 E.Arranging The Sheep
题目大意一个由“*”和“.”组成的字符串,求移动多少次“*”才可以使所有“*”连在一起思路找出最中间的那只羊,让其他羊向中看齐。AC代码#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;typedef long long ll;const int N=1e6+7;char a;int w[N];原创 2021-05-11 21:22:54 · 90 阅读 · 0 评论 -
Codeforces global round 14 B Phoenix and Puzzle
思路大正方形必然是由平方个小正方形拼成,小正方形要么全是两个三角形拼成、要么全是四个三角形拼成。所以只需要判断n/2或者n/4是不是平方数即可#include <iostream>#include <algorithm>#include <cmath>using namespace std;int main(){ int t; cin>>t; while(t--){ int n; cin>>n; if(n==2|.原创 2021-05-09 16:49:01 · 125 阅读 · 0 评论