【xsy1097】 拼图 构造题
题目大意:请你使用n个图形拼成一个矩形。要求:①这每个图形都由1×1的小正方形组成,而且第i个图形由i个小正方形组成。②除了第1个和第2个图形以外,任意一个图形的所有小正方形,不都在一条直线上。
数据范围:n≤1000
当n为奇数时,我们这么构造:
当n为偶数时,我们n为奇数的基础上,在原矩阵下方加多两排n就好了。
#include<bits/stdc++.h>
#define M 2005
using namespace std; int a[M][M]={}; int main(){
int n,m; scanf("%d",&n); m=(n+)/;
int hh=; if(n%==) hh=,n--;
for(int i=;i<=m;i++) a[n+][i]=a[n+][i]=n+;
for(int x=n,i=;x>m;x--,i++){
int nowx=i+,nowy=i;
for(int j=;j<=x;j++,nowx++){
if(a[nowx][nowy]) nowx--,nowy++;
a[nowx][nowy]=x;
}
}
for(int x=m,i=;x>;x--,i+=){
int nowx=,nowy=i;
for(int j=;j<=x;j++,nowx++){
if(a[nowx][nowy]) nowx--,nowy++;
a[nowx][nowy]=x;
}
x--;
for(int j=;j<=x;j++,nowx++){
if(a[nowx][nowy]) nowx--,nowy++;
a[nowx][nowy]=x;
}
}
printf("%d %d\n",n+(hh*),m);
for(int i=;i<=n+(hh*);i++,printf("\n"))
for(int j=;j<=m;j++) printf("%d ",a[i][j]);
}
【xsy1097】 拼图 构造题的更多相关文章
- cf251.2.C (构造题的技巧)
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...
- hdu4671 Backup Plan ——构造题
link:http://acm.hdu.edu.cn/showproblem.php?pid=4671 其实是不难的那种构造题,先排第一列,第二列从后往前选. #include <iostrea ...
- Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...
- Codeforces 482 - Diverse Permutation 构造题
这是一道蛮基础的构造题. - k +(k - 1) -(k - 2) 1 + k , 1 , k , 2, ....... ...
- BZOJ 3097: Hash Killer I【构造题,思维题】
3097: Hash Killer I Time Limit: 5 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 963 Solved: 36 ...
- CF1110E Magic Stones(构造题)
这场CF怎么这么多构造题…… 题目链接:CF原网 洛谷 题目大意:给定两个长度为 $n$ 的序列 $c$ 和 $t$.每次我们可以对 $c_i(2\le i<n)$ 进行一次操作,也就是把 $c ...
- CDOJ 1288 旅游的Final柱 构造题
旅游的Final柱 题目连接: http://acm.uestc.edu.cn/#/problem/show/1288 Description 柱神要去打Final啦~(≧▽≦)/~啦啦啦 柱神来到了 ...
- CodeForces 297C Splitting the Uniqueness (脑补构造题)
题意 Split a unique array into two almost unique arrays. unique arrays指数组各个数均不相同,almost unique arrays指 ...
- HDU 5355 Cake (WA后AC代码,具体解析,构造题)
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others) ...
随机推荐
- shell的一些简单用法
一 BASH的属性 BASH中会存储一些自身属性的参数,启用或关闭某一项功能 例如控制* .字符是否为通配 查看参数 set -o 关闭noglob参数 set -o noglob ls * ls: ...
- 数塔问题-hdu-2084(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084 思路:要求从顶到底的最大值,可以反过来考虑,从底部向上. 只有下面一行的最大值确定,这一行的最大 ...
- 1024 Hello World
哈哈,原来今天是程序员的节日啊,快乐咯,可是今天好冷好冷~~
- C程序之修改Windows的控制台大小
//change the console size #include <stdio.h> #include<stdlib.h> //必须有 int main(int argc, ...
- 全国各地dns服务器列表
211.103.13.101 江苏省无锡市 移动DNS服务器 211.136.28.231 北京市 移动DNS服务器 211.136.28.234 北京市 移动DNS服务器 211.136.28.23 ...
- 201709012工作日记--一台电脑创建两个Github账户上传代码
1. 在一台主机上面使用多个GitHub账号 有时候,我们需要将个人账号和公司账号区分,这时候我们就会需要在一台电脑上使用2个不同的git账号. 2. 上传文件 http://blog.csdn.ne ...
- Getting Started with Google Tango(Google Tango开始教程)
https://developers.google.com/tango/ Build apps that understand space and motion in high fidelity on ...
- readLine() 和 "\r","\n" 问题
很多输入流中都有一个函数readLine(),我们也经常使用这个函数,但有时如果不认真考虑,这个函数也会带来一些小麻烦. 如果我们是从控制台读入的话,我们也许没有想过readLine函数到底是根据&q ...
- jsp ckeditor ckfinder
我认为对的事情,有可能是完全错的. 这篇教程很好: http://www.cnblogs.com/yuepeng/archive/2013/04/01/2992097.html 只看到9,权限控制还没 ...
- Moving XML/BI Publisher Components Between Instances
As it is well known fact that XMLPublisher stores the metadata and physical files for templates and ...