CF1393A.Rainbow Dash, Fluttershy and Chess Coloring

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

One evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal.

The game starts on a square flat grid, which initially has the outline borders built up. Rainbow Dash and Fluttershy have flat square blocks with size 1×11\times1, Rainbow Dash has an infinite amount of light blue blocks, Fluttershy has an infinite amount of yellow blocks.

The blocks are placed according to the following rule: each newly placed block must touch the built on the previous turns figure by a side (note that the outline borders of the grid are built initially). At each turn, one pony can place any number of blocks of her color according to the game rules.

Rainbow and Fluttershy have found out that they can build patterns on the grid of the game that way. They have decided to start with something simple, so they made up their mind to place the blocks to form a chess coloring. Rainbow Dash is well-known for her speed, so she is interested in the minimum number of turns she and Fluttershy need to do to get a chess coloring, covering the whole grid with blocks. Please help her find that number!

Since the ponies can play many times on different boards, Rainbow Dash asks you to find the minimum numbers of turns for several grids of the games.

The chess coloring in two colors is the one in which each square is neighbor by side only with squares of different colors.

一天晚上,云宝黛西和小蝶想出了一个游戏。由于这两只小马是朋友,她们决定不在游戏中竞争,而是共同追求一个目标。

游戏在一个初始时仅构建了边框的方形平面网格上开始。云宝黛西和小蝶各自拥有大小为 1×11\times1 的平面正方形方块:云宝黛西拥有无限多个天蓝色方块,小蝶拥有无限多个黄色方块。

方块的放置需遵循如下规则:每个新放置的方块必须与之前各轮已构建出的图形(注意:网格的边框在游戏开始时即已存在)有一条边相邻。在每一轮中,其中一只小马可以按游戏规则放置任意数量的、属于她自己颜色的方块。

云宝黛西和小蝶发现,她们能以这种方式在游戏网格上构建出各种图案。她们决定先从简单的情形入手,因此计划将方块摆放成国际象棋棋盘式的双色染色(即棋盘格染色)。众所周知云宝黛西速度极快,因此她很关心:要完成覆盖整个网格的棋盘格染色,她和小蝶最少需要多少轮?请帮她求出这个最小轮数!

由于这两只小马会在不同尺寸的棋盘上多次进行游戏,云宝黛西请你针对若干个不同尺寸的游戏网格,分别求出所需的最少轮数。

所谓棋盘格双色染色,是指网格中每个方格仅与其上下左右(即边相邻)的方格颜色不同。

输入格式

The first line contains a single integer TT (1≤T≤1001 \le T \le 100): the number of grids of the games.

Each of the next TT lines contains a single integer nn (1≤n≤1091 \le n \le 10^9): the size of the side of the grid of the game.

第一行包含一个整数 TT(1≤T≤1001 \le T \le 100):游戏的网格数量。

接下来的 TT 行,每行包含一个整数 nn(1≤n≤1091 \le n \le 10^9):该游戏网格的边长。

输出格式

For each grid of the game print the minimum number of turns required to build a chess coloring pattern out of blocks on it.

对于游戏中的每个网格,输出在其上用方块构建棋盘着色图案所需的最少步数。

输入输出样例

  • 输入#1

    2
    3
    4

    输出#1

    2
    3

说明/提示

For 3×33\times3 grid ponies can make two following moves:

对于 3×33\times3 网格,小马可以执行以下两种移动:

输入解题思路,AI测评打分。不知道怎么写?

首页