Codeforces Round #564 (Div. 2)B
B. Nauuo and Chess
题目链接:http://codeforces.com/contest/1173/problem/B
题目
Nauuo is a girl who loves playing chess.
One day she invented a game by herself which needs n chess pieces to play on a m×m chessboard. The rows and columns are numbered from 1 to m. We denote a cell on the intersection of the r-th row and c-th column as (r,c)
The game's goal is to place n chess pieces numbered from 1 to n on the chessboard, the i-th piece lies on (ri,ci), while the following rule is satisfied: for all pairs of pieces i and j, |ri−rj|+|ci−cj|≥|i−j|. Here |x| means the absolute value of x.
However, Nauuo discovered that sometimes she couldn't find a solution because the chessboard was too small.
She wants to find the smallest chessboard on which she can put n
pieces according to the rules.
She also wonders how to place the pieces on such a chessboard. Can you help her?
Input
The only line contains a single integer n(1≤n≤1000) — the number of chess pieces for the game.
Output
The first line contains a single integer — the minimum value of m, where m
is the length of sides of the suitable chessboard.
The i-th of the next n lines contains two integers ri and ci (1≤ri,ci≤m) — the coordinates of the i-th chess piece.
If there are multiple answers, print any.
Example
input
2
output
2
1 1
1 2
题意
给你一个数,你在方格中放这1~n这些数,使得任意两个数a->b在方格中走的格数大于等于|a-b|的值
输出1~n每个数的位置
思路
给你一个表格即可发现规律
1 | 2 | ||
3 | 4 | ||
5 | 6 | ||
行走路径为先向下再向右,两数之间步数与差值都相等
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n;
cin>>n;
cout<<n/+<<endl;
for(int i=;i<=n;i++)
{
cout<<(i+)/<<' '<<i/+<<endl;
} return ;
}
Codeforces Round #564 (Div. 2)B的更多相关文章
- Codeforces Round #564 (Div. 1)
Codeforces Round #564 (Div. 1) A Nauuo and Cards 首先如果牌库中最后的牌是\(1,2,\cdots, k\),那么就模拟一下能不能每次打出第\(k+i\ ...
- Codeforces Round #564 (Div. 2) C. Nauuo and Cards
链接:https://codeforces.com/contest/1173/problem/C 题意: Nauuo is a girl who loves playing cards. One da ...
- Codeforces Round #564 (Div. 2) B. Nauuo and Chess
链接:https://codeforces.com/contest/1173/problem/B 题意: Nauuo is a girl who loves playing chess. One da ...
- Codeforces Round #564 (Div. 2) A. Nauuo and Votes
链接:https://codeforces.com/contest/1173/problem/A 题意: Nauuo is a girl who loves writing comments. One ...
- Codeforces Round #564 (Div. 2)A
A. Nauuo and Votes 题目链接:http://codeforces.com/contest/1173/problem/A 题目 Nauuo is a girl who loves wr ...
- Codeforces Round #564 (Div. 2) D. Nauuo and Circle(树形DP)
D. Nauuo and Circle •参考资料 [1]:https://www.cnblogs.com/wyxdrqc/p/10990378.html •题意 给出你一个包含 n 个点的树,这 n ...
- Codeforces Round #564 (Div. 2)
传送门 参考资料 [1]: the Chinese Editoria A. Nauuo and Votes •题意 x个人投赞同票,y人投反对票,z人不确定: 这 z 个人由你来决定是投赞同票还是反对 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 利用WPF的ListView进行大数据量异步加载
原文:利用WPF的ListView进行大数据量异步加载 由于之前利用Winform的ListView进行大数据量加载的时候,诟病良多,所以今天试着用WPF的ListView来做了一下,结果没有让我失望 ...
- flash导出正常清晰(无色差)GIF图片
前言: 这枚GIF算是半临摹作品.我使用的FLASH制作这个小动画,其实这类型的动画用AE做会更便捷. 进入主题前,先摆出个成品 教程结束,以上就是flash制作出来的小动画怎么导出正常清晰(无色差) ...
- 系统引导文件之 boot.ini(有很多参数)
Windows NT类的操作系统,也就是Windows NT/2000/XP中,有一个特殊文件,也就是“BOOT.INI”文件,这个文件会很轻松地按照我们的需求设置好多重启动系统. “BOOT.INI ...
- redis 从0到1 linux下的安装使用 数据类型 以及操作指令 一
安装 redis 到 /usr/目录下 我这里安装的是redis-3.2.9.tar.gz tar zxvf redis-3.2.9.tar.gz -C /usr 然后进行 执行编译命令 mak ...
- js如何通过变量调用函数,函数名在变量里面
js如何通过变量调用函数,函数名在变量里面. 有时候函数名是动态定义的,这时候我们就需要用到这个方法了. //赋值函数名称 var a = "b"; //定义函数 function ...
- php 获取今日、昨日、本周,上周、本月,上月,季度的起始时间戳和结束时间戳的方法
php 获取今日.昨日.上周.本月的起始时间戳和结束时间戳的方法,主要使用到了 php 的时间函数 mktime.下面首先还是直奔主题以示例说明如何使用 mktime 获取今日.昨日.上周.本月的起始 ...
- Qt SizePolicy 属性(每个控件都有一个合理的缺省sizePolicy。QWidget.size()默认返回值是(640, 480),QWidget.sizeHint()默认返回值是(-1, -1))
控件的sizePolicy说明控件在布局管理中的缩放方式.Qt提供的控件都有一个合理的缺省sizePolicy,但是这个缺省值有时不能适合 所有的布局,开发人员经常需要改变窗体上的某些控件的sizeP ...
- Windows 10开发基础——XML和JSON (二)
主要内容: Linq to XML Newtonsoft.Json.Linq来解析JSON 博客园RSS(http://www.cnblogs.com/rss)的解析 UWP调用自己实现的Web AP ...
- UWP项目生成错误: 未能使用“CompileXaml”任务的输入参数初始化该任务。“CompileXaml”任务不支持“PlatformXmlDir”参数。请确认该参数存在于此任务中,并且是可设置的公共实例属性。
UWP项目生成错误: 未能使用“CompileXaml”任务的输入参数初始化该任务.“CompileXaml”任务不支持“PlatformXmlDir”参数.请确认该参数存在于此任务中,并且是可设置的 ...
- A Summaryof JDBC
Die Sonne gewinnen! I think it's easy to understand what is JDBC used for. Programer's program shoul ...