UVALive - 7269 I - Snake Carpet
思路:
多画画就发现从五的时候可以这么填:

六的时候这么填:

七的时候这么填:

看出规律了吗?
没看出的话再画画把。
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; int main(void)
{
int n,h,w;
//freopen("out.acm","w",stdout);
while(~scanf("%d",&n))
{
if(n==) printf("1 1\n1 1\n");
else if(n==) printf("1 3\n1 1\n1 2 1 3\n");
else if(n==) printf("2 3\n1 2\n1 3 2 3\n1 1 2 1 2 2\n");
else if(n==)
printf("2 5\n1 2\n1 3 2 3\n1 1 2 1 2 2\n2 4 1 4 1 5 2 5\n");
else if(n==)
printf("3 5\n1 2\n3 4 3 5\n1 1 2 1 2 2\n2 4 1 4 1 5 2 5\n3 1 3 2 3 3 2 3 1 3\n");
else
{
h=(n+)/,w=(n/-)*+;
printf("%d %d\n",h,w);
printf("1 2\n3 4 3 5\n1 1 2 1 2 2\n2 4 1 4 1 5 2 5\n3 1 3 2 3 3 2 3 1 3\n");
for(int i=;i<=n;i++)
if(i&)
{
int x=(i+)/,j=;
while(j<i)
printf("%d %d ",x,j++);
printf("%d %d\n",x-,j-);
}
else
{
int x=i/-+(i==n),mx=i/+(i!=n);
while(x)
printf("%d %d ",x--,i);
x=;
while(x<mx)
printf("%d %d ",x++,i+);
printf("%d %d\n",x,i+);
}
}
}
return ;
}
UVALive - 7269 I - Snake Carpet的更多相关文章
- UVALive 7269 Snake Carpet (构造)
题目:传送门. 题意:构造出一个矩阵,使得矩阵含有n条蛇,每条蛇的长度是1到n,并且奇数长度的蛇有奇数个拐弯,偶数长度 的蛇有偶数个拐弯. 奇数和偶数分开构造,奇数可以是: 1357 3357 555 ...
- UVaLive 7269 Snake Carpet (找规律,模拟)
题意:给定一个数字n,表示有n条蛇,然后蛇的长度是 i ,如果 i 是奇数,那么它只能拐奇数个弯,如果是偶数只能拐偶数个,1, 2除外,然后把这 n 条蛇, 放到一个w*h的矩阵里,要求正好放满,让你 ...
- 构造 hihocoder 1257 Snake Carpet (15北京I)
题目传送门 题意:贪吃蛇,要求长度奇数的蛇转弯次数为正奇数,长度偶数转弯次数为正偶数,且组成矩形.(北大出的题咋都和矩形相关!!!) 分析:构造找规律,想到就简单了.可以构造 宽:(n + 1) / ...
- 【hihocoder 1257 Snake Carpet】构造
2015北京区域赛现场赛第4题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...
- hihoCoder 1257 Snake Carpet(很简单的构造方法)
2015 ACM / ICPC 北京现场赛 I 题 构造 注意一个小坑,每条蛇的输出是要从头到尾输出的. 还要注意的是,不能开数组去模拟构造过程,然后输出,那样会TLE的. #include < ...
- hiho1257 Snake Carpet
题目链接:http://hihocoder.com/problemset/problem/1257 题目大意:有n条蛇 编号为1-n 每条蛇的长度跟编号相等 奇数编号的蛇必须拐奇数次(除了第一条)偶数 ...
- [LeetCode] Design Snake Game 设计贪吃蛇游戏
Design a Snake game that is played on a device with screen size = width x height. Play the game onli ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
随机推荐
- Unity3D笔记 模型和角色动画的输出设置
- Ubuntu 16.04系统下软件中心Software闪退解决办法
按住Ctrl+Alt+T打开终端输入: sudo apt-get update //更新 sudo apt-get dist-upgrade //升级 sudo apt-get install --r ...
- iOS - viewDidLoad, viewWillDisappear, viewWillAppear区别及加载顺序
viewWillAppear: Called when the view is about to made visible. Default does nothing视图即将可见时调用.默认情况下不执 ...
- Centos7 安装hive
安装hive 配置hive 在hdfs中新建目录/user/hive/warehouse 首先启动hadoop任务 hdfs dfs -mkdir /tmp hdfs dfs -mkdir /user ...
- poj3614 Sunscreen【贪心】
Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11772 Accepted: 4143 Descri ...
- URAL 1277 - Cops and Thieves - [无向图点带权的最小点割]
题目链接:https://cn.vjudge.net/problem/URAL-1277 The Galaxy Police (Galaxpol) found out that a notorious ...
- TACOTRON:端到端的语音合成
tacotron主要是将文本转化为语音,采用的结构为基于encoder-decoder的Seq2Seq的结构.其中还引入了注意机制(attention mechanism).在对模型的结构进行介绍之前 ...
- python数据结构之树(二叉树的遍历)
树是数据结构中非常重要的一种,主要的用途是用来提高查找效率,对于要重复查找的情况效果更佳,如二叉排序树.FP-树. 本篇学习笔记来自:二叉树及其七种遍历方式.python遍历与非遍历方式实现二叉树 介 ...
- date 命令之日期和秒数转换
时间转为秒数 date -d "2012-11-12 13:00:00" +"%s" 描述转为日期 date -d@1352692800 +"%Y-% ...
- 反面教材 构造构造 json 数据
构造构造 json 数据 说说你们在项目中遇到过的最糟糕的代码 - V2EX https://www.v2ex.com/t/214099