A. Rainbow Dash, Fluttershy and Chess Coloring

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

Input
The first line contains a single integer T(1≤T≤100): the number of grids of the games.
Each of the next T lines contains a single integer n (1≤n≤109): the size of the side of the grid of the game.
Output
For each grid of the game print the minimum number of turns required to build a chess coloring pattern out of blocks on it.

Example
Input
2
3
4

Output
2
3

Note

For 3×3 grid ponies can make two following moves:

在这里插入图片描述

#include<iostream> 
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		int x;
		cin>>x;
		cout<<x/2+1<<endl;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Dash中,`dash.js`是Dash内部使用的JavaScript库,用于处理与交互相关的功能,其中包括plotly.js的封装。`dash.js`中并没有直接设置`bns`的代码,因为`bns`是plotly.js的配置选项,它是在`dcc.Graph`的`config`属性中设置的。 当用户与图表交互时,`dash.js`会发送请求到Dash后端,后端会根据请求参数生成新的图表,并将其返回给前端。在生成新的图表时,后端会根据`dcc.Graph`的`config`属性中的设置来生成plotly.js的配置,并将其传递给新的图表。因此,`bns`的设置是在后端代码中实现的。 具体来说,在Dash后端代码中,`bns`的默认值是通过`plotly.graph_objs`模块中的`layout`对象来设置的,例如: ```python import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go app = dash.Dash(__name__) app.layout = html.Div([ dcc.Graph( id='example-graph', figure={ 'data': [ {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'}, {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'Montreal'}, ], 'layout': go.Layout( title='Dash Data Visualization', barmode='stack', xaxis={'title': 'X Axis'}, yaxis={'title': 'Y Axis'}, # 设置buffer size为128 bns=128 ) } ) ]) if __name__ == '__main__': app.run_server(debug=True) ``` 在上面的示例中,使用`go.Layout`来设置图表的布局信息,其中包括`bns`的设置。在后端代码中,根据`dcc.Graph`的`config`属性中的设置来生成plotly.js的配置,并将其传递给新的图表。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值