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 ...
随机推荐
- C#代码实现矢量画图
原文:C#代码实现矢量画图 版权声明:本文为博主原创文章,转载请附上链接地址. https://blog.csdn.net/ld15102891672/article/details/80275969 ...
- OpenGL(十八) 顶点数组和抗锯齿(反走样)设置
顶点数组函数可以在一个数组里包含大量的与顶点相关的数据,并且可以减少函数的调用.使用顶点数组需要先启用顶点数组功能,使用glEnableClientState函数启用顶点数组,参数可以是GL_VERT ...
- Android 百度地图 SDK v3.0.0 (四) 离线地图功能介绍
转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/37758097 一直认为地图应用支持离线地图非常重要啊.我等移动2G屌丝,流量不易 ...
- 首个 C++ 编译器诞生 30 周年了,来听听 C++ 之父畅谈 C++
原文 http://www.iteye.com/news/31076 C++ 之父 Bjarne Stroustrup 在 cfront 诞生 30 周年的访谈. 整整30年前,CFront 1 ...
- 二维码彩色广告招牌的切割制作问题(C#.net下对彩色二维码圆角样式及改进)
原文:二维码彩色广告招牌的切割制作问题(C#.net下对彩色二维码圆角样式及改进) 我们知道,目前二维码还很少用于广告招牌的制作.但随着智能手机越来越普及,互联网等网络的应用也越来越广泛,作为连接物理 ...
- WMWaire使用FreeNAS硬盘挂载、Raid0
FreeNAS硬盘挂载.Raid0 发表于2012 年 03 月 28 日由admin 创建成功,FreeBSD的Hardware显示状态 今天,我们将在VMware工具的帮助下,学习“FreeNAS ...
- ELINK编程器典型场景之序列号烧写
序列号烧写功能是指往指定的FLASH存储位置写入产品序列号.由于产品序列号写入到FLASH存储位置,启用序列号功能需要考虑以下几个方面:如果您的应用使能了读保护,则解除读保护将触发全片擦除机制,序列号 ...
- 【Gerrit】Performance Cheat Sheet
首先说下做这件事情的主因,组内有人说Project repo sync有点慢,废话不多说,直接上图. 相关官方文档参考链接: 我的数据: ~/review_site/logs# fgrep " ...
- 查看 Linux 发行版本的名称以及版本号
查看LINUX发行版的名称及其版本号的命令: lsb_release -a cat /etc/redhat-release(针对redhat,Fedora)
- 使用NEWSEQUENTIALID解决GUID聚集索引问题
原文:使用NEWSEQUENTIALID解决GUID聚集索引问题 UNIQUEIDENTIFIER做主键(Primary Key)是一件很方便的事情,在数据合并等操作中有不可替代的优势 但是由于普通的 ...