Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) A. CME
链接:
https://codeforces.com/contest/1241/problem/A
题意:
Let's denote correct match equation (we will denote it as CME) an equation $$\(a + b = c\)$$ there all integers $$\(a\)$$, $$\(b\)$$ and $$\(c\)$$ are greater than zero.
For example, equations $$\(2 + 2 = 4\)$$ (||+||=||||) and $$\(1 + 2 = 3\)$$ (|+||=|||) are CME but equations $$\(1 + 2 = 4\)$$ (|+||=||||), $$\(2 + 2 = 3\)$$ (||+||=|||), and $$\(0 + 1 = 1\)$$ (+|=|) are not.
Now, you have $$\(n\)$$ matches. You want to assemble a CME using all your matches. Unfortunately, it is possible that you can't assemble the CME using all matches. But you can buy some extra matches and then assemble CME!
For example, if $$\(n = 2\)$$, you can buy two matches and assemble |+|=||, and if $$\(n = 5\)$$ you can buy one match and assemble ||+|=|||.
Calculate the minimum number of matches which you have to buy for assembling CME.
Note, that you have to answer $$\(q\)$$ independent queries.
思路:
超过2的偶数可以拆成1 1 2的比例, 奇数加一个也可以满足.
代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
if (n == 2)
cout << 2 << endl;
else if (n%2 == 0)
cout << 0 << endl;
else
cout << 1 << endl;
}
return 0;
}
Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) A. CME的更多相关文章
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature【枚举二分答案】
https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the rea ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) D. Sequence Sorting
链接: https://codeforces.com/contest/1241/problem/D 题意: You are given a sequence a1,a2,-,an, consistin ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) B. Strings Equalization
链接: https://codeforces.com/contest/1241/problem/B 题意: You are given two strings of equal length s an ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature
链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1)
Virtual participate 的,D题不会做,打了1:30就打不动了,过了ABCE. A - CME 题意:? 题解:? void test_case() { int n; scanf(&q ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) 题解
A..B略 C 对当前的值排序,再二分答案,然后对于(i%x==0 && i%y==0)放入大的,再放其他的贪心解决即可. #include<iostream> #incl ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...
- Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3
A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最 ...
- 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...
随机推荐
- [Agc029C]Lexicographic constraints_进制_二分答案_贪心
Lexicographic constraints 题目链接:https://atcoder.jp/contests/agc029/tasks/agc029_c 数据范围:略. 题解: 二分是显然的, ...
- javaSE 笔记一
java 环境变量配置 步骤: 右键[计算机]图标 –>[属性]–>[高级系统设置]–>[环境变量] 在"系统变量"里找到"Path" ...
- Python之random.seed()用法
import random # 随机数不一样 random.seed() print('随机数1:',random.random()) random.seed() print('随机数2:',rand ...
- STM32之DMA实例
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/zouleideboke/article/details/75092558 DMA简介: DMA(Di ...
- Docker学习+遇坑笔记
基础命令: 1.Docker启动:docker-machine start default 2.Docker关闭: docker-machine stop default 3.查看当前运行的Dock ...
- Linux weblogic启停
一般weblogic启停在windows下很方便使用图标方式.但是在linux下需要杀掉weblogic进程才能真正关掉weblogic. 1.查询weblogic进程 ps -ef | grep & ...
- 《深入理解 Java 虚拟机》学习 -- Java 内存模型
<深入理解 Java 虚拟机>学习 -- Java 内存模型 1. 区别 这里要和 JVM 内存模型区分开来: JVM 内存模型是指 JVM 内存分区 Java 内存模型(JMM)是指一种 ...
- [转载]AdaBoost算法
[转载]AdaBoost算法 原文:https://blog.csdn.net/v_july_v/article/details/40718799 这里就不转载了,到原文看吧.但是有几点可以注意下: ...
- Advanced Installer 安装完成后,自动启动主程序。
这个耗时2天,才研究测试通过.一定要记住了方法: =========================================================================== ...
- Subplots
数据读取: Subplotting 先展示下我们在画一张图时的步骤 生成一个matplotlib Figure对象 生成一个matplotlib AxesSubplot 对象,然后将其赋值给Figur ...