题目链接:https://vjudge.net/contest/231314#problem/D

Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex.

Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!).

Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins?

Peter is pretty good at math, but now he asks you to help.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make.

The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test.

Output

Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.

Examples

Input
31 2 3

Output
211

Input
51 1 5 1 1

Output
22222

Note

In the first sample test:

In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses.

In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses.

In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins.

In the second sample test:

Having cycles of size 1 is like not having them (because no one can make a move on them).

In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3.

  • If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses.
  • If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins.

So, either way first player loses.

题目大意:n代表有n个测试样例,下面n组数,注意后面的数的结果是在前面数的结果之上出来的,大概意思就是给你一组数,假设一个数是

x,你可以用两个数来替换它,p,x-p,把所有数换成1的是谁,先走的赢输出1,后走的赢输出2。

个人思路:以为是到很难的博弈题,然后在草稿本上推公式,应该是推出来了,但是超时了,然后优化,优化了之后变成runtime了,数组范围

不够,但是又不能开的要的那么大,所以过不了,只能搜题解了。 题解很简单,就是一个数要变成1的话要n-1次,所以只要统计有多少次就行

了,是不是特别水的题,,,,

看代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<set>
#include<queue>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int maxn=1e5+10;
const ll maxa=1e8;
#define INF 0x3f3f3f
//#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{int n;ll sum=0;ll a[maxn];cin>>n;for(int i=0;i<n;i++)cin>>a[i];for(int i=0;i<n;i++){sum+=a[i]-1;if(sum%2)cout<<"1"<<endl;elsecout<<"2"<<endl;}return 0;
}

下面这道是我见过最水的题,没有之一

题目链接:http://codeforces.com/problemset/problem/710/B

You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.

Input

The first line contains integer n (1 ≤ n ≤ 3·105) — the number of points on the line.

The second line contains n integers xi ( - 109 ≤ xi ≤ 109) — the coordinates of the given n points.

Output

Print the only integer x — the position of the optimal point on the line. If there are several optimal points print the position of the leftmost one. It is guaranteed that the answer is always the integer.

Example

Input
41 2 3 4

Output
2题目大意:输入n,代表 有n个坐标,下面给出n个坐标,求哪个点所有点到它的距离和最小个人思路:以为给出的是各个点的大小,给出顺序是坐标,想的挺复杂,然后完全偏离方向,嗯。。。  很水
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<set>
#include<queue>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int maxn=3e5+10;
const ll maxa=1e10;
#define INF 0x3f3f3f3f3f3f
int a[maxn],b[maxn];
int main()
{int n;cin>>n;for(int i=0;i<n;i++){cin>>a[i];}sort(a,a+n);if(n%2==0)cout<<a[n/2-1];elsecout<<a[n/2];return 0;
}

转载于:https://www.cnblogs.com/caijiaming/p/9316156.html

超级大水题(还是自己过不了的水题)相关推荐

  1. 【Leetcode每日一题】118. 杨辉三角(水题)

    Leetcode每日一题 题目链接: 118. 杨辉三角 难度: 简单 解题思路: 无.见代码. 题解: class Solution:def generate(self, numRows: int) ...

  2. 蓝桥杯 第三届C/C++预赛真题(7) 放棋子(水题)

    今有 6 x 6 的棋盘格.其中某些格子已经预先放好了棋子.现在要再放上去一些,使得:每行每列都正好有3颗棋子.我们希望推算出所有可能的放法.下面的代码就实现了这个功能. 初始数组中,"1& ...

  3. 【qduoj - 夏季学期创新题】最长公共子串(水题暴力枚举,不是LCS啊)

    题干: 描述 编写一个程序,求两个字符串的最长公共子串.输出两个字符串的长度,输出他们的最长公共子串及子串长度.如果有多个最长公共子串请输出在第一个字符串中先出现的那一个. 特别注意公共子串中可能包含 ...

  4. CodeForces - 1293C NEKO's Maze Game(思维,水题)

    题目链接:点击查看 题目大意:给出一个2*n大小的矩阵,现在有m次操作,每次操作将某一个方格的状态置反,这里的每个方块都有两种状态,一种状态是可通行状态,另一种是不可通行状态,初始时所有方块都是可通行 ...

  5. 最详细最简单:最大公因数求法、辗转相除法、更相减损法,入门ACM,杭电水题,算法递归,初级算法题一看就懂

    文章目录 前言 一.名称定义 1.最大公约数 2.辗转相除法 3.更相减损法 二.ACM杭电入门题 1.解题思路 三.解题参考代码(C语言,C++) 0.最优算法(C++) 1.辗转相除求解(C语言) ...

  6. 【UR #7】水题走四方

    题目描述 今天是世界水日,著名的水题资源专家蝈蝈大臣发起了水题走四方活动,向全世界发放成千上万的水题. 蝈蝈大臣是家里蹲大学的教授,当然不愿意出门发水题啦!所以他委托他的助手欧姆来发. 助手欧姆最近做 ...

  7. POJ 1003 Hangover 水题

    题目看着挺复杂,还配了个看上去就很高大上的图,但是看完题就发现,完完全全是一道水题= =好吧,题意简单说就是有一排数,是1/2,1/2+1/3,1/2+1/3+1/4.......然后给出一个数,问这 ...

  8. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  9. HDU2091 空心三角形 水题

    空心三角形 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

最新文章

  1. 浅析SAAS数据模型设计(Oracle)
  2. 查看凭证更改记录的三种方式
  3. python红色的颜色表达式_50行Python代码实现视频中物体颜色识别和跟踪(必须以红色为例)...
  4. 用管控策略设定多账号组织全局访问边界
  5. SAP Fiori Elements原理介绍之类型为Value Help的Smart Field工作原理
  6. node怎么把token放到redis_从零开始手写 redis(八)朴素 LRU 淘汰算法性能优化
  7. 算法设计和数据结构学习_2(常见排序算法思想)
  8. win7x64 连接oracle 客户端 vs 2010调试 提示“ORA-12154: TNS: 无法解析指定的连接标识符 ”
  9. 温度控制直流电动机的c语言,温度控制直流电动机转速系统设计报告
  10. matlab 高维矩阵转置,matlab中关于矩阵的转置
  11. 超声广义相干因子( Generalized Coherence Factor,GCF)波束合成仿真
  12. 教你用Python感受量子霸权
  13. CRM SaaS是什么?
  14. Tipask,Tipask建站,Tipask插件
  15. linux小说编辑,Fade In Pro——剧本小说编辑软件
  16. 甘肃非税收缴实现“一网通办”:随时随地扫码“搞定”
  17. 二进制#逻辑计算#与(∧)、或(∨)、非(¬)、异或(⨁)#与,或,非,异或的运算法则#与,或,非,异或运算的基础代码
  18. 网易100天---46、Things You Need to Know About Snapchat
  19. 摇骰子小程序源码_喝酒聚会怕冷场,就找摇塞子小程序!
  20. 服务器分区有什么作用,公认很好的无盘网吧服务器硬盘分区划分和使用经验

热门文章

  1. FOJ 1887 景区摊位安排问题
  2. 建立windows2003 域名服务器
  3. PhpMyAdmin 配置文件现在需要一个短语密码的解决方法
  4. 解决安装YouCompleteMe与Vim版本不兼容问题
  5. pip 更新版本失败问题解决
  6. 解决Linux里面未启用网卡的问题
  7. 图解抖音推荐算法(布局抖音短视频的可以参考)
  8. 业界分享 | 美团到店综合知识图谱的构建与应用
  9. 东南亚跨境电商为什么推荐ERP仓储系统?
  10. linux 终端 画圆,Linux Bash Shell快速入门