![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
爱打酱油的剑姬
这个作者很懒,什么都没留下…
展开
-
Stas and the Queue at the Buffet
Problem - D - Codeforceshttps://codeforces.com/contest/1151/problem/D题目的意思 : 给你一个数组 , 让你找出一个最小的答案当前位置 的答案 ai *(j-1) + bi * (n-j)这个公式 可以转换成 ai * j + ai + bi * n - bi * j ---------> (ai - bi ) * j + bi * n - ai如果 让答案变小 只能改变 (ai - bi ) * j , bi*...原创 2022-02-28 10:53:51 · 141 阅读 · 0 评论 -
Bubble Sort Graph
题目意思让你找一个最长的升序子序列#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3f#define _for(i,a,b) for(int i=a;i<=b;i++)#define for_(i,a,b) for(int i=a;i<b;i++)#define _fr(i,a,b) for(int i=a;i>=b;i--)原创 2022-02-13 22:29:49 · 310 阅读 · 0 评论 -
Two TVs
Problem - C - Codeforces题目意思 你有2台电视,问你能不能看完视频解题思路可以定义两个变量 如果俩个变量在看电视但是下一个节目开始了,那就说明看不完全部节目#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3f#define _for(i,a,b) for(int i=a;i<=b;i++)#define for原创 2022-02-13 16:20:52 · 339 阅读 · 0 评论 -
Cat Party (Easy Edition)
题目的意思:让你找出最大的一个长度x,1 - x 之间( 可以删除 或者 不删)一个数字, 让1-x之间的所有数字数量相同,找出最长的位置。解题思路:一:1 每种颜色的出现次数都是1。2 只有一种颜色出现次数最多,且出现次数为I。3 一种颜色的出现次数为1,其他颜色的出现次数相同。4 一种颜色的出现次数比任何其他颜色都多1次#include <iostream>#include <stdio.h>using namespace std;const .原创 2022-02-13 13:49:28 · 107 阅读 · 0 评论 -
Minimize the error
Problem - B - Codeforceshttps://codeforces.com/contest/960/problem/B题目意思是给你 长度为n , a数组进行k1 次操作,b数组k2次操作每次操作能 +1 or -1解题思路把每个的a和b的结对值先计算出来,题目要绝对值的平方,因为要让答案变小,让大的绝对值变小能使最后总结果变小,那么可以使用优先队列来解此题#include"bits/stdc++.h"#define ll long long#define pi.原创 2022-02-13 00:58:40 · 102 阅读 · 0 评论 -
Months and Years
题意 : 是给你n个月份让你让你判断是否存在解题思路把所有的年份加在一起然后用字符串函数判断是否存在就行了#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3f#define _for(i,a,b) for(int i=a;i<=b;i++)#define for_(i,a,b) for(int i=a;i<b;i++)#defin原创 2022-01-30 21:55:55 · 505 阅读 · 0 评论 -
PawnChess
题目意思2个人走 8*8 的地图 谁先走到第一个谁先赢W只能往上走 , B 只能往下走 (棋子被挡住了就无法走了)#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3f#define _for(i,a,b) for(int i=a;i<=b;i++)#define for_(i,a,b) for(int i=a;i<b;i++)...原创 2022-01-28 22:29:28 · 357 阅读 · 0 评论 -
Megacity
题目意思 在0,0点开始 想要找到 大于1e6 的最小的最大半径如果找不到输出-1#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3f#define _for(i,a,b) for(int i=a;i<=b;i++)#define for_(i,a,b) for(int i=a;i<b;i++)#define IOS ios...原创 2022-01-28 14:24:06 · 819 阅读 · 0 评论 -
Vladik and Complicated Book
题意给你一个 n 长数组 ,m 次排序 让你看看第x位的数组是否发生改变l - r 之间的数从小到大排的 , 因此我们只要看当前数在排序的数字中排第几 ,就可以判定是否相等#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3f#define _for(i,a,b) for(int i=a;i<=b;i++)#define for_(i,a,b)原创 2022-01-28 13:05:09 · 439 阅读 · 0 评论 -
Table Tennis Game 2
题目意思 是俩个人一起打球 k分为一个回合 ,一人a赢了分,一人b分,问你可以打几个回合假如 a < k && b < k 那肯定一个回合都没有假如 a>k && b > k 肯定可以组成多个回合假如 其中一个小于k 那要判定另一个 是不是k的倍数了 ,如果是倍数可以提前打完一个回合,不是的话,当失败者打完全部分数还没有到达一个回合,那铁定是失败的#include"bits/stdc++.h"#define ll long lo..原创 2022-01-28 12:12:57 · 622 阅读 · 0 评论 -
Bear and Strings
遍历,每次找到“bear”,就用该串前面个字符数x,以及该串后面的字符数y,ans += (x+1)*(y+1)- 前一个“bear”所在位置的字符串(重复的)#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3fusing namespace std;const int N = 1e5+5;int s[N];void solve(){ .原创 2022-01-23 21:21:17 · 352 阅读 · 0 评论 -
Numbers on the Chessboard
解题思路 根据 x+y的 来判定是否为一个数字较大的数#include"bits/stdc++.h"#define ll long long#define pi pair<int,int>#define inf 0x3f3f3f3fusing namespace std;const int N = 1e5+5;int s[N];void solve(){ ll n,k,q; cin >> n >> q; while (q--){原创 2022-01-23 20:41:00 · 287 阅读 · 0 评论 -
Codehorses T-shirts
这里可以用到 multiset 这个容器c++语言中,multiset是<set>库中一个非常有用的类型,它可以看成一个序列,插入一个数,删除一个数都能够在O(logn)的时间内完成,而且他能时刻保证序列中的数是有序的,而且序列中可以存在重复的数。这里有别的博主详细介绍的(8条消息) multiset用法总结_二喵君的博客-CSDN博客_multisethttps://blog.csdn.net/sodacoco/article/details/84798621?ops_reques原创 2022-01-23 15:13:33 · 302 阅读 · 0 评论 -
Powers of Two
You are givennintegersa1, a2, ..., an. Find the number of pairs of indexesi, j(i < j) thatai + ajis a power of2(i. e. some integerxexists so thatai + aj = 2x).题目意思让你找有多少个2个组合的数字能是2的幂方直接暴力搜#include "bits/stdc++.h"#define ll long l...原创 2022-01-15 22:05:19 · 278 阅读 · 0 评论 -
Bear and Elections(优先对列)
#include "bits/stdc++.h"using namespace std;int n,x,xx;priority_queue<int,vector<int>,less<int>>q;int main(){ cin >> n; cin >> x; for(int i=1;i<n;i++){ cin >> xx; q.push(xx); } .原创 2022-01-15 22:01:14 · 98 阅读 · 0 评论 -
Box(模拟)
#include "bits/stdc++.h"using namespace std;const int N = 1e5+5;int t,n;int s[N],vis[N];int main(){ cin >> t; while (t--){ memset(vis,0,sizeof vis); cin >> n; for(int i=1;i<=n;i++) cin >> s[i]; .原创 2022-01-13 17:30:24 · 82 阅读 · 0 评论 -
Coins
#include "bits/stdc++.h"using namespace std;map<char,int>mp;char a,b,c;int main(){ for(int i=0 ;i < 3 ; i ++) { cin >> a >> b >> c; if(b == '<'){ mp[c]++; mp[a]+=0; .原创 2022-01-13 17:29:13 · 88 阅读 · 0 评论 -
Ohana Cleans Up
#include "bits/stdc++.h"using namespace std;int n;map<string,int>mp;string s;int main(){ cin >> n; int ans = 0; for(int i=0;i<n;i++){ cin >> s; mp[s]++; ans= max(ans,mp[s]); } cout &l.原创 2022-01-13 17:28:20 · 101 阅读 · 0 评论 -
SwapSort
#include "bits/stdc++.h"#define ll long longusing namespace std;ll n;ll s[3005];ll v[3005];vector<pair<ll,ll>>pr;int main(){ cin >> n; for(int i=0;i<n;i++){ cin >> s[i]; v[i]=s[i]; } if(is.原创 2022-01-13 17:27:20 · 96 阅读 · 0 评论 -
Row(模拟)
#include "bits/stdc++.h"using namespace std;int n;string s;int main(){ cin >> n; cin >> s; bool flag = true; if(n==1 && s=="0") flag= false; int l = 0; while (l<n) { if(l == 0){ ...原创 2022-01-13 17:25:24 · 82 阅读 · 0 评论 -
Caisa and Sugar
#include "bits/stdc++.h"using namespace std;int n,s,x,y;int main(){ cin >> n >> s; int ans = -1; for(int i=0 ; i < n ; i++){ cin >> x >> y; if(x == s && y == 0){ ans = max(ans.原创 2022-01-13 17:22:28 · 45 阅读 · 0 评论 -
Nastya and an Array
#include "bits/stdc++.h"using namespace std;int n,x;map<int,int>mp;int main(){ while (cin >> n){ mp.clear(); for(int i=1;i<=n;i++){ cin >> x; if(x != 0){ mp[x]++; ...原创 2022-01-13 17:21:09 · 120 阅读 · 0 评论 -
Right-Left Cipher
简单模拟#include "bits/stdc++.h"using namespace std;deque<char>d;string s;int main(){ while (cin >> s){ for(int i=0 ; i< s.size();i++){ d.push_back(s[i]); } string str ; int len = s.size.原创 2022-01-13 17:19:59 · 56 阅读 · 0 评论 -
Blackjack
J 、Q、K、10 4个暴力就行了#include "bits/stdc++.h"using namespace std;int n;map<int,int>mp;int main(){ // 2 3 4 5 6 7 8 9 10 A 1 | 11 10 10 10 10 16 while (cin >> n) { int cnt = 0; int f = 0; for(int i原创 2022-01-13 17:18:43 · 92 阅读 · 0 评论 -
CQXYM Count Permutations
#include "bits/stdc++.h"#define ll long longusing namespace std;const ll N = 1e9+7;ll t,n;int main(){ cin >> t; while (t--) { cin >> n; ll ans = 1; for(int i=1;i<=2*n;i++){ ans *=i; .原创 2022-01-13 17:15:44 · 71 阅读 · 0 评论 -
Educational Codeforces Round 118 (Rated for Div. 2)
A:Long Comparison题目就是给你 2个数字 每一个数字后面跟着多少个零 比较大小思路就是直接用字符串比较#include "bits/stdc++.h"using namespace std;int t;int a,b,q,w;int main(){ cin >> t; while (t--){ cin >> a >> q; cin >> b >> w; ..原创 2021-12-04 01:30:06 · 962 阅读 · 0 评论 -
Codeforces Round #756 (Div. 3)
Dashboard - Codeforces Round #756 (Div. 3) - Codeforceshttps://codeforces.com/contest/1611A. Make Even题目让你找把一个整数变成一个偶数最少能变几次分类讨论1.他原本就是一个偶数 ,无需变化2.他是 一个奇数 , 如果是一个奇数看看有没有偶数的位数 有 最多交换2次 最少1次在有的情况下,第一位是偶数 那只需1次反之2次。在每位都是奇数的情况下你无法交换成偶数所以是不能成功的 ..原创 2021-11-26 09:33:31 · 117 阅读 · 0 评论 -
Minimum Extraction
#include"bits/stdc++.h"#define ll long longusing namespace std;const int N = 2e5+5;ll t,n,m,l;ll s[N];int main(){ ios::sync_with_stdio(false); cin >> t; while (t--) { cin >> n; for(int i=1 ;i<=n;i++) .原创 2021-11-05 22:09:41 · 145 阅读 · 0 评论 -
Odd Grasshopper
#include"bits/stdc++.h"#define ll long longusing namespace std;const int N = 1e6+5;ll t,n,m;string a,b;int main(){ ios::sync_with_stdio(false); cin >> t; while (t--) { cin >> n >> m; ll ans = m % 4.原创 2021-11-05 22:06:14 · 217 阅读 · 0 评论 -
A The Miracle and the Sleeper
水题 只要知道数学公式就行了找出2个数中最大的取模值#include "bits/stdc++.h"#define ll long longusing namespace std;ll t;int main(){ cin >> t; while (t--) { ll l,r; cin >> l >> r; if((r/2+1)>l){ // r/2+1 &.原创 2021-08-31 15:50:46 · 140 阅读 · 0 评论 -
B. Scenes From a Memory (水题)
题目的意思就是给你一个数让他不是质数写法 1、4、6、8、9都不是质数如果有直接输出就行了假设都没有那么 就找2位不是质数的,2位没有找3位,这题范围可能2位数就行了,所以一个埃氏筛下就好了#include "bits/stdc++.h" using namespace std;int t,n;string s;int vis[1005];void ss(){ for(int i=2;i<=1000;i++){ if(!vis[i]){原创 2021-08-31 15:54:43 · 180 阅读 · 0 评论 -
C. Rings
题目意思就是第一个 l-r 内二进制转十进制的值大于第二个 l-r#include "bits/stdc++.h" using namespace std;int t,n,k;string s;int main(){ cin >> t; while (t--){ cin >> n >> s; int f = s.find('0'); // 判断有无0 有0最好写了 if(f !...原创 2021-08-31 16:14:01 · 217 阅读 · 0 评论 -
A. A Variety of Operations
只能说水题 ,看懂题目规则就行了#include "bits/stdc++.h" using namespace std;int t;int a,b;int main(){ cin >> t; while (t--) { cin >> a >> b; // 题目给你2个0 能不能改成他给的俩个数, 2个数为一奇一偶肯定 不能成功直接-1, 否则俩个相同并且不为0 ..原创 2021-08-31 16:31:29 · 89 阅读 · 0 评论 -
Codeforces Beta Round #1(B. Spreadsheets)
这题就是进制转换 (这里是26进制)#include "bits/stdc++.h" using namespace std;int t;string s;map<char,int>mp;// 判断是转换的是哪一种类型bool ss(string sl){ int len = sl.size(); int g=0; for(int i=0;i<len;i++){ if(g==0 && s[i]>='A'&a.原创 2021-09-03 13:53:46 · 119 阅读 · 0 评论 -
Codeforces Round #736 (Div. 2)(C. Web of Lies)
这题我是看别人的博客才看明白这题是讲的是什么 看了别人的写法感觉很优秀学了一下别人的写法。题意告诉你有多少人 ,给你m条信息告诉你关系 , 然后在q条信息 1 代表谁和谁成为朋友 2代表谁和谁不是朋友了 3 输出还剩多少人;这题规则就是虚弱的人要死亡规则:一个人要有朋友,才会死亡;#include "bits/stdc++.h" using namespace std;const int N = 2e5+5;int s[N],n,m,k,q,x,y;int main(){..原创 2021-09-04 16:31:40 · 117 阅读 · 1 评论 -
Codeforces Round #739 (Div. 3)(B. Who‘s Opposite?)
这题的题意是给你3个数 x,y,z 首先 x对应的是y 其次 让你找出z的对应值 找到输出 没找到输出 -1#include "bits/stdc++.h" using namespace std;int t;int main(){ cin >> t; while (t--) { int x,y,z; cin >> x >> y >> z; int k = ab...原创 2021-09-04 19:47:55 · 100 阅读 · 0 评论 -
Codeforces Round #739 (Div. 3)(C. Infinity Table)
题意就是这张图表题目给你数字 让你找出行列#include "bits/stdc++.h"#define ll long longusing namespace std;ll t,n;int main(){ cin >> t; while (t--) { cin >> n; ll k = sqrt(n); // 用找出的n的是 第几行或者是第几列的 if(k*k<n){.原创 2021-09-05 00:00:11 · 97 阅读 · 0 评论 -
Codeforces Round #723 (Div. 2)(B. I Hate 1111)
本人比较菜,一直找不到规律 直到看了别人的博客 才知道 所有符合条件都是 111*a+11*b = n#include "bits/stdc++.h"using namespace std;int t,n;int main(){ cin >> t; while (t--) { cin >> n; int f=0; for(int i=0 ; i < 11 ; i ++){ ...原创 2021-09-08 13:05:11 · 59 阅读 · 0 评论 -
Sort the Array
题意就是给你一组数组 让你改变一段 能不能变成递增的数组想了好久怎么用模拟 但是看了别人的reverse()函数的使用 第一次知道还可以这样使用#include "bits/stdc++.h"using namespace std;const int N = 1e5+5;int s[N],n;int main(){ cin >> n; int l=1,r=1; for(int i=1;i<=n;i++){ cin >&g.原创 2021-09-14 22:25:23 · 81 阅读 · 0 评论 -
Number of Ways
题意就是给你一个数组 让你分成3个区间 能不能让3个区间里面的值都相等解题方法 用一个前缀和先统计出所有的1/3的值个数 碰到 2/3 就加一次1/3的总个数 就知道可以分为几个区间了代码有点乱#include "bits/stdc++.h"#define ll long longusing namespace std;const int N = 5e5+5;ll n,s[N];int main(){ cin >> n; for(int ...原创 2021-09-15 19:12:07 · 114 阅读 · 0 评论