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 ...
随机推荐
- 《The C Programming Language》学习笔记
第五章:指针和数组 单目运算符的优先级均为2,且结合方向为自右向左. *ip++; // 将指针ip的值加1,然后获取指针ip所指向的数据的值 (*ip)++; // 将指针ip所指向的数据的值加1 ...
- yum源 epel源 替换及安装
#!/bin/sh # 备份yum源 zip -r /etc/yum.repos.d/yum_resource_back_up.zip /etc/yum.repos.d/* # 替换yum源 wget ...
- Servlet的request和response
SERVLET API中forward() 与redirect()的区别? 答:前者仅是容器中控制权的转向,在客户端浏览器地址栏中不会显示出转向后的地址:后者则是完全的跳转,浏览器将会得到跳转的地址 ...
- Centos7下关闭Firewalls配置iptables
在网上搜索了很多这种资料,现在总结一下以备后用. 1.关闭防火墙:sudo systemctl stop firewalld.service 2.关闭开机启动:sudo systemctl disab ...
- 关于MD5加盐使用
md5 是一种数据加密,例子是对123456 进行了两次加盐 第一次是 inputPassToFormPass salt是固定的 1a2b3c4d 第二次是 formPassToDBPass s ...
- 关于JS原型以及原型链、instanceof的一些理解
一.JS原型 首先要区分两个概念 1.构造函数 2.实例:由构造函数通过new方式创建出来的就是实例 <script> function Foo() { } var f = new Foo ...
- docker-compose搭建elasticsearch+kibana环境,以及php使用elasticsearch
一.elasticsearch的Dockerfile 增加中文搜索插件analysis-ik FROM docker.elastic.co/elasticsearch/elasticsearch:7. ...
- CentOS7 PHP cURL errno 35, 原因:CentOS7中没有安装curl和OpenSSL的最新版
安装OpenSSL的最新版 话不多说,直接上安装步骤 #cd /usr/local/src # 跳过证书获取失败 # wget https://www.openssl.org/source/opens ...
- python 修改文件的创建时间、修改时间、访问时间
目录 python 修改文件创建.修改.访问时间 方案一 方案二(无法修改文件创建时间) python 修改文件创建.修改.访问时间 突如其来想知道一下 python 如何修改文件的属性(创建.修改. ...
- MyBatis学习存档(5)——联表查询
之前的数据库操作都是基于一张表进行操作的,若一次查询涉及到多张表,那该如何进行操作呢? 首先明确联表查询的几个关系,大体可以分为一对一和一对多这两种情况,接下来对这两种情况进行分析: 一.建立表.添加 ...