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 ...
随机推荐
- WPF4文字模糊不清晰、边框线条粗细不一致的解决方法
原文:WPF4文字模糊不清晰.边框线条粗细不一致的解决方法 软件测试过程中发现在一台1600*900的分辨率电脑上文字模糊,甚至某些个文字出现压缩扭曲 经过实践,发现按下面方法能解决一点问题: 在窗口 ...
- 测试了下boost的序列化反序列化功能
// testSerialization.cpp : Defines the entry point for the console application. // #include "st ...
- 标准差standard deviation和标准错误standard error你能解释一下
by:ysuncn(欢迎转载,请注明原创信息) 什么是标准差(standard deviation)呢?依据国际标准化组织(ISO)的定义:标准差σ是方差σ2的正平方根:而方差是随机变量期望的二次偏差 ...
- 目标检测的图像特征提取(一)HOG特点
1.HOG特点: 方向梯度直方图(Histogram of Oriented Gradient, HOG)特征是一种在计算机视觉和图像处理中用来进行物体检測的特征描写叙述子.它通过计算和统计图像局部区 ...
- C#中将字符串转换成Md5值的方法
原文:C#中将字符串转换成Md5值的方法 版权声明:有问题可联系博主QQ:15577969,大家一起相互交流和学习. https://blog.csdn.net/qq15577969/article/ ...
- C#调用JS
cmd调用phantomjs 官方资料:http://phantomjs.org/quick-start.html 手动执行 从官方下载phantomjs.exe,拷贝它与要执行的js同目录打开cmd ...
- 数据绑定(三)为Binding指定绑定源的几种方法
原文:数据绑定(三)为Binding指定绑定源的几种方法 Binding的源是数据的来源,所以,只要一个对象包含数据并能通过属性把数据暴露出来,它就能当作Binding的源来使用,常用的办法有: 一. ...
- google的开源项目总结(转载)
转自http://www.feng5166.com/blog/424.html google的开源项目值得我们一用的,这些项目很有意义,甚至可以直接用在我们自己的工作上!学习编程的的一个比较好的方式就 ...
- Win8Metro(C#)数字图像处理--2.18图像平移变换
原文:Win8Metro(C#)数字图像处理--2.18图像平移变换 [函数名称] 图像平移变换函数TranslationProcess(WriteableBitmap src,int x,in ...
- C#基础加强篇—委托、Lambda表达式和事件(下)
3.事件 事件作为C#中的一种类型,为类和类的实例定义发出通知的能力,从而将事件和可执行代码捆绑在了一起.事件是对象发送的消息,以发信号通知操作的发生.操作可能是由用户交互引起的,也可能是由某些其他的 ...