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 ...
随机推荐
- BZOJ 1483 HNOI2009 梦幻布丁 名单+启示录式的合并
标题效果:特定n布丁.每个人都有一个颜色布丁,所有的布丁反复有一定的颜色变化的颜色,颜色反复询问的段数 数据范围:n<=10W 色彩数<=100W 启发式合并名单0.0 从来不写清楚 实际 ...
- vector删,erase和remove难怪--【STL】
供vector使用容器.通常只是一个简单的遍历查找,其他操作已执行,这不是,今天,稍有不慎. erase方法的操作是将此时的节点删除,然后指向被删除节点的下一个: 如对数据1 6 6 4 7; #in ...
- 重构qDebug()<<,使log输出到文件
重构qDebug()<<,使log输出到文件 #include <QProcessEnvironment> #include <QDateTime> #includ ...
- WPF 窗体中获取键盘和鼠标无操作时的超时提示
原文:WPF 窗体中获取键盘和鼠标无操作时的超时提示 通过调用Windows API中的GetLastInputInfo来获取最后一次输入的时间 , , ); timer.Tic ...
- 王立平--android这四个组成部分
Android中称为四大组件的为别为:Activity/Service/BroadCast Recevicer/Content provider Activity:activity是用户和应用程序交 ...
- MVC HttpUtility.HtmlEncode是如何编码的
using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;us ...
- requirejs教程(一):基本用法
介绍 RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的RequireJS压缩后只有14K,堪称非常轻量.它还同时可以和其他的框架协同工作,使 ...
- MFC应用程序配置不正确解决方案(manifest对依赖的强文件名,WinSxs是windows XP以上版本提供的非托管并行缓存)
[现象] 对这个问题的研究是起源于这么一个现象:当你用VC++2005(或者其它.NET)写程序后,在自己的计算机上能毫无问题地运行,但是当把此exe文件拷贝到别人电脑上时,便不能运行了,大致的错误提 ...
- 什么是OTC?
OTC(Over The Counter)非处方药物,我国卫生部医政司是这样定义的:它是消费者可不经过医生处方,直接从药房或药店购买的药品,而且是不在医疗专业人员指导下就能安全使用的药品,即不需要凭借 ...
- Qt Widget 利用 Qt4.5 实现酷炫透明窗体
本文讲述的是Qt Widget 利用 Qt4.5 实现酷炫透明窗体,QWidget类中的每一个窗口部件都是矩形,并且它们按Z轴顺序排列的.一个窗口部件可以被它的父窗口部件或者它前面的窗口部件盖住一部分 ...