当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3849:Settlers of Catan

题目描述
The popular board game "Settlers of Catan" starts by creating a random board. This board consists of hexagonal resource tiles containing five different resources: clay, lumber, wool, grain, and ore. For simplicity, we will denote these by the numbers 1 to 5.
Random boards, however, often have multiple equal resource tiles next to each other. This annoys some players. Therefore, we have invented a new way of creating the playing board. Starting in the middle and spiraling outwards, each time we add a new tile to the board we choose the resource of the tile according to the following rules:
1. the new tile must be different from its neighboring tiles on the board so far;
2. in case multiple tiles are possible, we choose a resource that occurs the least number of times on the board so far;
3. in case multiple tiles are still possible, the new resource must have the lowest number possible.
The figure underneath shows how to spiral outwards and which resource tiles are chosen first. We are curious what the number of the resource is on the nth tile that is added to the board (starting with n = 1).
输入解释
On the first line of the input there is one integer c (1 <= c <= 200), the number of test cases. Each following test case consists of a single line with one integer n (1 <= n <= 10 000), the number of the tile we are curious about.
输出解释
For each test case, print a single line with one integer, specifying the resource of the nth tile.
输入样例
4
1
4
10
100
输出样例
1
4
5
5

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3849

最后修改于 2020-10-29T07:13:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536