链接:

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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) 题解

    A..B略 C 对当前的值排序,再二分答案,然后对于(i%x==0 && i%y==0)放入大的,再放其他的贪心解决即可. #include<iostream> #incl ...

  7. 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. 题解:很显然只有 \( ...

  8. 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) 思路:我们想一下如果题目说的是最 ...

  9. 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)

    比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...

随机推荐

  1. poj3449(判断直线相交)

    题目链接:https://vjudge.net/problem/POJ-3449 题意:给出若干几何体,判断每个几何体与其它几何体的相交情况,并依次输出. 思路: 首先要知道的是根据正方形对角线的两个 ...

  2. [转帖]什么是WAL?

    什么是WAL? https://www.cnblogs.com/hzmark/p/wal.html 原来数据库与消息中间件 用的是相同的模式 都是基于 顺序写的性能优于 离散写 series 强于sc ...

  3. SQLite进阶-17.视图

    目录 视图(View) 操作视图 更新视图 删除视图 查看所有的视图 视图(View) 视图是一个预定义的SQLite查询的形式存在的表的组合. 可以包含一个表的所有行或从一个或多个表选定行.可以从一 ...

  4. Codeforces contest 1277 E. Beautiful Rectangle

  5. 使用Google提供的ZXing Core,Java生成、解析二维码

    1.maven项目中,pom.xml中引入ZXing Core工具包: <!-- https://mvnrepository.com/artifact/com.google.zxing/core ...

  6. (十一)springMvc 异常处理

    文章目录 思路 自定义异常处理类 全局异常处理器 配置全局异常处理器 思路 在 springMvc 中,异常一层一层的往上抛,最后抛给 前端控制器,前端控制器内部会去找 全局异常处理器(一个系统只会有 ...

  7. spark调优篇-数据倾斜(汇总)

    数据倾斜 为什么会数据倾斜 spark 中的数据倾斜并不是说原始数据存在倾斜,原始数据都是一个一个的 block,大小都一样,不存在数据倾斜: 而是指 shuffle 过程中产生的数据倾斜,由于不同的 ...

  8. ButterKnife8.5.1最新版本使用详细步骤

    android studio中使用方法: 1.build.gradle(Modul: app) 添加dependencies{ compile 'com.jakewharton:butterknife ...

  9. NetScaler Logs Collection Guide

    NetScaler Logs Collection Guide 来源  https://support.citrix.com/article/CTX227560 Article | Authentic ...

  10. JPA的API介绍、工具类抽取

    1.Persistence对象 Persistence对象主要作用是用于获取EntityManagerFactory对象的 .通过调用该类的createEntityManagerFactory静态方法 ...