Codeforces 918(div4)

Problem - A - Codeforces

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N]; int main()
{
long long n;
cin >> n; while(n --)
{
int a , b , c;
cin >> a >> b >> c; if(a == b) cout << c << endl;
else if(a == c) cout << b << endl;
else if(b == c) cout << a << endl;
}
return 0;
}

Problem - B - Codeforces

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10; int main()
{
long long n;
cin >> n; while(n --)
{
char a[4][4] = {0};
int x , y;
for(int i = 1 ; i <= 3 ; i ++)
{
for(int j = 1 ; j <= 3 ; j ++)
{
cin >> a[i][j];
if(a[i][j] == '?')
{
x = i;
y = j;
}
} }
bool sta = false;
bool stb = false;
bool stc = false;
for(int i = 1 ; i <= 3 ; i ++)
{
if(a[x][i] != '?')
{
if(a[x][i] == 'A') sta = true;
if(a[x][i] == 'B') stb = true;
if(a[x][i] == 'C') stc = true;
}
if(a[x][i] == '?') continue;
}
if(!sta) cout << "A" << endl;
else if(!stb) cout << "B" << endl;
else if(!stc) cout << "C" << endl;
}
return 0;
}

Problem - C - Codeforces

注意一下判断 是否为平方数的方法;也要记得开long long

#include<bits/stdc++.h>
using namespace std; bool check(long long p)
{
long long m = sqrt(p);
return (long long)m * m == p;
} int main()
{
long long n;
cin >> n; while(n --)
{
long long m;
cin >> m;
long long sum = 0; for(int i = 1 ; i <= m ; i ++)
{
long long b;
cin >> b;
sum += b;
} if(check(sum)) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}

Problem - D - Codeforces

正序写 讨论的情况比较多,所以选择倒叙看;

#include <bits/stdc++.h>
using namespace std;
char p[] = {'a','e'};
char q[] = {'b','c','d'}; int check1(char y) //判断是否为V
{
for(int i = 0;i < 2;i++)
if(p[i] == y) return 1;
return 0;
} int check2(char y)//判断是否为C
{
for(int i = 0 ;i < 3;i++)
if(q[i] == y) return 1;
return 0;
} int main()
{
int t;
cin >> t; while(t--)
{
int n;
cin >> n; string a;
cin >> a; string ans;
//倒着看情况少 好写代码
//倒着看 只要第一个符合C那么就往前看是不是满足CVC
//如果是V就看他前一个是不是C;
for(int i = n - 1;i >= 0;i--)
{
ans.push_back(a[i]);
if(check2(a[i]) && check1(a[i-1]) && check2(a[i-2])) //如果符合CVC
{
ans.push_back(a[i-1]);
ans.push_back(a[i-2]);
ans.push_back('.');
i -= 2;
} else if(check1(a[i]) && check2(a[i-1])) //如果符合CV
{
ans.push_back(a[i-1]);
ans.push_back('.');
i -= 1;
}
} for(int i = ans.size()- 2;i >= 0;i--) //要从ans.size()-2开始;
cout << ans[i]; cout << endl;
} return 0;
}

Problem - E - Codeforces

根据题目要求 找出一段奇数的和 和 偶数的和相等的序列就输出yes,否则就输出no
a^l + a^(l+2) + ..+a^r = a^(l+1) + a^(l+3) +...+a^(r-1);
移项:
a^l - a^(l+1) + a^(l+2) - a^(l+3) +...+a^r-a^(r-1) = 0;
就找出这个式子; 也就是奇数项 - 偶数项 得到为0就代表YES
然后如果不是0 那么我们就要将这个数据记录下来,如果再次出现这个数据,那么就代表从出现过这个数据 后面的奇数项-偶数项的差值为0;那么也是输出YES
否则就输出no
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int a[N]; int main()
{
int t;
cin >> t; while(t--)
{
int n;
cin >> n; for(int i = 1 ; i <= n ; i ++) cin >> a[i]; long long sum = 0;
map<long long , int>st;
bool success = false;
for(int i = 1 ; i <= n ; i ++)
{
if(i & 1) sum += a[i]; //奇数就加
else sum -= a[i];//偶数就减 if(sum == 0 || st[sum]) //sum等于0 或者 这个sum又出现过一次
{
cout << "yes" << endl;
success = true;
break;
}
else
{
st[sum] ++; //记录这个sum出现过
}
}
if(!success) cout << "NO" << endl;
} return 0;
}

Codeforces 918(div4)的更多相关文章

  1. Codeforces 918 括号匹配 SGdp[i][j][k]

    A B C #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) ...

  2. Codeforces #640 div4 F~G (构造二连弹)

    题意:求一个只由\(01\)组成的字符串,使得它所有长度为\(2\)的子串满足:每对子串的数字和为\(0,1,2\)的个数为\(a,b,c\). 题解:我们先考虑子串数字和为\(1\)的情况,构造出一 ...

  3. Codeforces 918C The Monster(括号匹配+思维)

    题目链接:http://codeforces.com/contest/918/problem/C 题目大意:给你一串字符串,其中有'('.')'.'?'三种字符'?'可以当成'('或者')'来用,问该 ...

  4. codeforces的dp专题

    1.(467C)http://codeforces.com/problemset/problem/467/C 题意:有一个长为n的序列,选取k个长度为m的子序列(子序列中不能有位置重复),求所取的k个 ...

  5. Codeforces 918D/917B - MADMAX

    传送门:http://codeforces.com/contest/918/problem/D 本题是一个组合游戏问题——DAG上的动态规划问题. 有一张有向无环图(DAG).有两个玩家在这张图上进行 ...

  6. Codeforces 918C/917A - The Monster

    传送门:http://codeforces.com/contest/918/problem/C 一个括弧串由字符‘(’和‘)’组成.一个正确的串可被递归地定义,定义如下: ①空串e是一个正确的串: ② ...

  7. Codeforces Round #690 (Div. 3)

    第一次 ak cf 的正式比赛,不正式的是寒假里 div4 的 Testing Round,好啦好啦不要问我为什么没有 ak div4 了,差一题差一题 =.= 不知不觉已经咕了一个月了2333. 比 ...

  8. [cf]Codeforces Round #784(Div 4)

    由于一次比赛被虐得太惨,,生发开始写blog的想法,于是便有了这篇随笔(找了个近期的cf比赛练练手(bushi))第一次写blog,多多包涵. 第二场cf比赛,第一场打的Div2,被虐太惨,所以第二场 ...

  9. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  10. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

随机推荐

  1. 【译】ASP.NET Core在 .NET Core 3.1 Preview 1中的更新

    .NET Core 3.1 Preview 1现在可用.此版本主要侧重于错误修复,但同时也包含一些新功能. 这是此版本的ASP.NET Core的新增功能: 对Razor components的部分类 ...

  2. GO 中的时间操作(time & dateparse)【GO 基础】

    〇.前言 日常开发过程中,对于时间的操作可谓是无处不在,但是想实现时间自由还是不简单的,多种时间格式容易混淆,那么本文将进行梳理,一起学习下. 官方提供的库是 time,功能很全面,本文也会详细介绍. ...

  3. 「ABC 218」解集

    E 倒流一下,然后把负权边置零后跑 MST 即可. #include<cstdio> #include<vector> #include<algorithm> us ...

  4. “&”控制命令的运行方式

    在Unix.Linux和类Unix系统中,& 符号有特定的意义,用于控制命令的运行方式.具体来说,& 在命令末尾使用时表示将该命令放入后台运行. 前台运行: 如果你在终端输入一个命令, ...

  5. fatal: 无法访问 'https://github.com/nmww/lingyun.git/':Failed to connect to github.com port 443 after 13 ms: Connection refused

    fatal: 无法访问 'https://github.com/nmww/lingyun.git/':Failed to connect to github.com port 443 after 13 ...

  6. 循序渐进介绍基于CommunityToolkit.Mvvm 和HandyControl的WPF应用端开发(9) -- 实现系统动态菜单的配置和权限分配

    在WPF应用端开发,它的界面类似于Winform端,因此我们也需要对系统的菜单进行动态配置,这样才能把系统的功能弹性发挥到极致,通过动态菜单的配置方式,我们可以很容易的为系统新增所需的功能,通过权限分 ...

  7. IntersectionObserver v2版本

    业务需要内容展示后日志打点,于是使用到了IntersectionObserver,实践中发现一个问题:如果内容出现在了可视区内,但是被其他元素遮挡住了,这时候仍然会打日志. 于是寻找解决方案,发现In ...

  8. 【Azure Logic App】在Azure Logic App中使用SMTP发送邮件示例

    问题描述 在Azure Logic App的官网介绍中,使用SMTP组件发送邮件非常简单(https://docs.azure.cn/zh-cn/connectors/connectors-creat ...

  9. Istio 入门(七):出入口网关 - 负载均衡和熔断等一系列功能

    本教程已加入 Istio 系列:https://istio.whuanle.cn 目录 5,出入口网关 istio-ingressgateway 部署服务 配置 Gateway 子版本 istio-e ...

  10. [Python急救站课程]凯撒密码加密与解密

    密码的解密是一个有趣的过程,凯撒密码也是一个较为简单的密码,是通过位移来解决的. 当我们把凯撒密码位移量设置为3时就可以用Python做出以下程序. 加密程序: plaincode = input(& ...