code forces 1173 B. Nauuo and Chess
本文链接:https://www.cnblogs.com/blowhail/p/10991237.html
B. Nauuo and Chess 原题链接:http://codeforces.com/contest/1173/problem/B
题目大意: 在一个m x m的棋盘中放n个棋子,满足 |ri−rj| + |ci−cj| ≥ |i−j| |ri−rj| + |ci−cj| ≥ |i−j| (r为行,c为列)
大致思路:找规律之后可以发现,斜对角线上可以放的最大棋子数满足1 3 5 7 ....
如图

因此,我们可以这样放棋子:

代码如下:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std; int main ()
{
int i,t,m,n,u,sum,maxs,mins,x,y,z;
scanf("%d",&n);
m=n/+; //根据规律,直接算出棋盘大小
printf("%d\n",m);
for(i=;i<=m;++i)
printf("%d %d\n",,i);
for(i=;i<=n-m+;++i)
printf("%d %d\n",i,m); return ;
}
code forces 1173 B. Nauuo and Chess的更多相关文章
- code forces 1173 C. Nauuo and Cards
本文链接:https://www.cnblogs.com/blowhail/p/10990833.html Nauuo and Cards 原题链接:http://codeforces.com/con ...
- 思维题--code forces round# 551 div.2
思维题--code forces round# 551 div.2 题目 D. Serval and Rooted Tree time limit per test 2 seconds memory ...
- Code Forces 796C Bank Hacking(贪心)
Code Forces 796C Bank Hacking 题目大意 给一棵树,有\(n\)个点,\(n-1\)条边,现在让你决策出一个点作为起点,去掉这个点,然后这个点连接的所有点权值+=1,然后再 ...
- Code Forces 833 A The Meaningless Game(思维,数学)
Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...
- 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 ...
- Code Forces 543A Writing Code
题目描述 Programmers working on a large project have just received a task to write exactly mm lines of c ...
- Codeforces 1173B Nauuo and Chess
题目链接:http://codeforces.com/problemset/problem/1173/B 思路参考:https://www.cnblogs.com/blowhail/p/1099123 ...
- code forces 383 Arpa's loud Owf and Mehrdad's evil plan(有向图最小环)
Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megab ...
- code forces 382 D Taxes(数论--哥德巴赫猜想)
Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...
随机推荐
- WPF 四种尺寸单位
原文:WPF 四种尺寸单位 像素 px 默认单位可以省略 厘米cm 英寸 in 点 pt 1in = 96px 1cm=96/2.42px 1pt=96/72px
- Why aren't more desktop apps written with Qt?(quora.com系列文章)
As far as I know and have understood in my experience with Qt, it's a very good and easy to learn li ...
- ubuntu 关闭 phpmyadmin
apache 有很多管理服务器的命令.apt-get installl phpmyadmin后突然想暂时关闭phpmyadmin,只需要a2disconf phpmyadmin即可.需要启用的时候再输 ...
- DotNetBar for Windows Forms 14.0.0.15_冰河之刃重打包版发布
关于 DotNetBar for Windows Forms 14.0.0.15_冰河之刃重打包版 --------------------11.8.0.8_冰河之刃重打包版------------- ...
- CSS visibility 属性 使元素占位,但不可见
CSS visibility 属性 使元素占位,但不可见 h2 { visibility:hidden; } 浏览器支持 所有主流浏览器都支持 visibility 属性. 注释:任何的版本的 Int ...
- thinkphp5 phpexcel基本设置
//引入类 header('Content-type: text/html; charset=utf-8'); import('Org.Util.PHPExcel'); import('Org.Uti ...
- List.Sort() 小小技巧--- 从大到小排列
List.sort() 默认的情况下是从小到大的排列. 例如: List<int> list = new List<int>(); list.Add(- ...
- delphi 程序强制结束自身(两种方法都暴力)
procedure KillSelf;begin Sleep(1000); if not TerminateProcess(GetCurrentProcessId, 0) then WinExe ...
- Windows下配置Redis,并修改密码
原文:Windows下配置Redis,并修改密码 Windows下配置Redis,并修改密码 下载 Redis Windows版本的GitHub链接,直接下载zip文件解压到指定文件夹下或者下载msi ...
- vista忘记用户名密码的修改方法(使用PE进入系统,用cmd.exe冒充虚拟键盘,然后就可以mmc组策略,或者命令行添加用户并提升权限)
1. 准备Windows Vista安装光盘,进入BIOS将光驱设为第一启动,在出现的安装界面依次单击"修复计算机","命令提示符". 2.输入以下命令: co ...