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 ...
随机推荐
- ASP.NET Core 配置 Entity Framework Core - ASP.NET Core 基础教程 - 简单教程,简单编程
原文:ASP.NET Core 配置 Entity Framework Core - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 配置 Entity Fram ...
- vs2013+cocos2d-x-2.2.3组态
win8/win8.1+vs2013+cocos2d-x-2.2.3组态 前言: 这是我人生第一篇博客,假设你认为不好,还请见谅!!!!! 工具: 1.vs2013 2.Python2.7(百度一大片 ...
- 【转载】使用Docker Hub官方gcc:latest镜像编译C/C++程序以及缩小镜像的方法
摘要:使用Docker Hub官方gcc:latest镜像(1.2GB)编译C/C++程序,以及缩小镜像的方法. 方法1: 在gcc容器里编译C/C++程序 将C/C++代码运行在gcc容器内的最简单 ...
- Lexer的设计--中(4)
设计一个小型的内存池以及链表 上一节撸到万事俱备只欠真正的lex, 但是lex的作用是将源代码转化为Token流, 用什么保存Token? 这就涉及到我们要接触的第一个数据结构-链表, 虽然标准库中很 ...
- C#破解access数据库密码方法
原文:C#破解access数据库密码方法 using System; using System.Collections.Generic; using System.IO; using System.L ...
- RESTful API设计原则与规范
RESTful API设计原则与规范 一.背景与基础概念 2 二.RESTful API应遵循的原则 3 1.协议(Protocol) 3 2.域名(ROOT URL) 3 3.版本(Versioni ...
- 使用mingw 对libcURL,openSSL,zLib交叉编译
使用mingw 对libcURL,openSSL,zLib交叉编译 将三个库解压到同一目录下 比如取目录名为 "source" 的目录 提前安装active-perl 配置 ...
- BI-学习之 新概念介绍
什么是统一维度模型 层次结构.级别.成员和度量值 什么是MDX MDX与SQL的区别 什么是数据仓库 什么是OLAP数据分析引擎 BI企业级解决方案 什么是统一维度模型 维度(dimension)是描 ...
- Qt4.8.6与VS2008的集成开发环境的安装配置
一.安装编译Qt 1. 在Windows下用Qt做开发,编译器可以用mingw的gcc/g++,也可以用VS. 2. 安装VS2008集成开发环境(完全安装). 3. 安装qt4.8.6(qt-op ...
- Terminator快捷键
窗口相关 窗口开关 上下开新窗口 Ctrl+Shift+O垂直开新窗口 Ctrl+Shift+E关闭当前窗口 Ctrl+Shift+W 改变当前激活窗口 逆时针改变当前窗口 Ctrl+Sh ...