链接:

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;
}

最新文章

  1. linux perf - 性能测试和优化工具
  2. 让reddit/r/programming炸锅的一个帖子,还是挺有意思的
  3. html5,output标签应用举例
  4. 以ls命令为实例介绍命令基本格式
  5. datepicker自定义 -- iOS
  6. App之百度云推送
  7. Repeat Header / Keep Header Visible in Tables in RS 2008
  8. Android开发之一些资源索引
  9. Wix installer: suppressing the License Dialog
  10. Egret HTTP网络
  11. openwrt看IP流量
  12. JavaScript 覆盖document.createElement 方法 解决window.close在火狐下不兼容问题)
  13. 一个Bug的反思
  14. CentOS 7 引导 -- GRUB2
  15. 通过内核修改centos密码
  16. Java和计算机科学课程的关系
  17. 毕业样本=[胡弗汉顿大学毕业证书]UoW原件一模一样证书
  18. Spring boot整合ElasticSearch案例分享+bboss
  19. 「【算法进阶0x30】数学知识A」作业简洁总结
  20. call,apply,bind——js权威指南函数属性和方法章节读书笔记

热门文章

  1. oracle不记得所有账户和密码怎么办
  2. ARC083E. Bichrome Tree
  3. Photon Server 实现注册与登录(一) --- Hibernate整合到项目中
  4. mysql innodb数据库损坏导致无法启动
  5. global和nonlocal的区别
  6. 安装HAXM报错:failed to configure driver unknown error. failed to open driver 并提示数字签证不可用
  7. C++遍历文件夹
  8. 【QT 学习笔记】 一、 VS2015+ QT环境安装
  9. 【转】axios用post提交的数据格式
  10. mybatis generator代码生成器的使用