cf 118B
2 seconds
256 megabytes
standard input
standard output
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handkerchief pattern should look like that:
0
0 1 0
0 1 2 1 0
0 1 2 3 2 1 0
0 1 2 3 4 3 2 1 0
0 1 2 3 4 5 4 3 2 1 0
0 1 2 3 4 3 2 1 0
0 1 2 3 2 1 0
0 1 2 1 0
0 1 0
0
Your task is to determine the way the handkerchief will look like by the given n.
The first line contains the single integer n (2 ≤ n ≤ 9).
Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line.
2
0
0 1 0
0 1 2 1 0
0 1 0
0
3
0
0 1 0
0 1 2 1 0
0 1 2 3 2 1 0
0 1 2 1 0
0 1 0
0
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i = ; i < n + ; i ++)
{
for(int j = ; j < i * + ; j ++)
{
for(int k = i* ; j== && k < n * ; k++ )cout<<" ";
if(j<=i&&j!=i*)cout<<j<<" ";
else if(j<=i)cout<<j;
else if(j!=i*)cout<<i*-j<<" ";
else cout<<i*-j;
}
cout<<endl;
}
for(int i = ; i < n ; i++)
{
for(int j = ; j < (n - i )* - ; j++)
{
for(int k = ; j==&& k < (i+)* ; k++)cout<<" ";
if(j<=n-i- && j!= (n-i)*-)cout<<j<<" ";
else if(j<=n-i-)cout<<j;
else if(j!=(n-i)*-)cout<<(n-i -)* -j <<" ";
else cout<<(n-i-)*-j;
}
cout<<endl; }
}
cf 118B的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
随机推荐
- Go语言入门篇-命令 与 语法
一.命令基础 1. go run : 用于运行命令源码文件(如:go run helloworld.go) 只能接受一个命令源码文件以及若干个库源码文件作为文件参数 其内部操作步骤: (1)先编译源码 ...
- 解决172.17 或者172.18 机房环境下harbor服务器不通的问题
直接改docker-compose.yml文件: 把原来的network选项注释掉,自定义 #networks: # harbor: # external: false networks: harbo ...
- 如何将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中
cat /etc/issue|tr '[:lower:]' [:upper:] >> /tmp/issue.out
- [转帖]Linux shell中2>&1的含义解释 (全网最全,看完就懂)
Linux shell中2>&1的含义解释 (全网最全,看完就懂) https://blog.csdn.net/zhaominpro/article/details/82630528 ...
- H264 RTP包解析
1. 预备 视频: 由一副副连续的图像构成,由于数据量比较大,因此为了节省带宽以及存储,就需要进行必要的压缩与解压缩,也就是编解码. h264裸码流: 对一个图像或者一个视频序列进行压缩,即产生码流 ...
- [BZOJ3451]Normal(点分治+FFT)
[BZOJ3451]Normal(点分治+FFT) 题面 给你一棵 n个点的树,对这棵树进行随机点分治,每次随机一个点作为分治中心.定义消耗时间为每层分治的子树大小之和,求消耗时间的期望. 分析 根据 ...
- 洛谷 - P1462 - 通往奥格瑞玛的道路 - 二分 - Dijkstra
https://www.luogu.org/problem/P1462 感觉,要二分最大收费权的城市,把小于等于它的全部插进去,Dijkstra一下求出最小的血量.这样感觉太暴力了. 考虑只有1000 ...
- pip和pip3的区别
安装了python3之后,会有pip3 1. 使用pip install XXX 新安装的库会放在这个目录下面 python2.7/site-packages 2. 使用pip3 install XX ...
- Timer的利用
package 第十一章; import java.util.*; import java.util.TimerTask; public class TimerTest { /** * @param ...
- Java8 将List转变为逗号分隔的字符串
import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Tes ...