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 ...
随机推荐
- 在VS2005中设置WPF中自定义按钮的事件
原文:在VS2005中设置WPF中自定义按钮的事件 上篇讲了如何在Blend中绘制圆角矩形(http://blog.csdn.net/johnsuna/archive/2007/08/13/17407 ...
- WPF 3D模型的一个扩展方法
原文:WPF 3D模型的一个扩展方法 在WPF 3D中,我们常常需要改变一个ModelVisual3D对象的颜色. 先说说ModelVisual3D,本质上3D模型都是由一个个的三角形构成的,并且经过 ...
- 熵、交叉熵、相对熵(KL 散度)意义及其关系
熵:H(p)=−∑xp(x)logp(x) 交叉熵:H(p,q)=−∑xp(x)logq(x) 相对熵:KL(p∥q)=−∑xp(x)logq(x)p(x) 相对熵(relative entropy) ...
- SQL Server 2017 正式发布:同时支持 Windows 和 Linux(现在看下来,当年那德拉的“云优先,移动优先”是有远见的,而且是有一系列的措施和产品相配合的,只是需要一点时间而已。真是佩服!!)
微软在去年 3 月首次对外宣布了 Linux 版的 SQL Server,并于今年 7 月发布了首个公开 RC 版.前几日在美国奥兰多召开的微软 Ignite 2017 大会上,微软宣布 SQL Se ...
- 031 二进制1的数量(keep it up, 看到这个问题,刚开始有点蒙)
剑指offer在标题中:http://ac.jobdu.com/problem.php?pid=1513 题目描写叙述: 输入一个整数,输出该数二进制表示中1的个数.当中负数用补码表示. 输入: 输入 ...
- 亲串 (hdu 2203 KMP)
亲串 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...
- Spring MVC 专题
Spring静态资源路径是指系统可以直接访问的路径,且路径下的所有文件均可被用户直接读取.在Springboot中默认的静态资源路径有:classpath:/META-INF/resources/,c ...
- Nucleus PLUS系统架构和组件
(一个)方法论和软件组件 1.软件组件(Software Component)定义 从一般意义上来说.组件(Component)是系统中能够明白辨识的组成部分,一个不透明的功能实现体.软件开发中,组件 ...
- 简历上的哪些内容才是 HR 眼中的干货?
资源业绩能力知识自评 https://www.zhihu.com/question/39722495/answer/199846861
- Java之nio MappedByteBuffer的资源释放问题
使用nio的MappedByteBuffer映射内存, 在最后执行File.delete()方法的时候, 返回false, 即文件没有被删除. 原因是MappedByteBuffer在内存中也会创建 ...