B. Present from Lena
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

The first line contains the single integer n (2 ≤ n ≤ 9).

Output

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.

Sample test(s)
Input
2
Output
    0
0 1 0
0 1 2 1 0
0 1 0
0
Input
3
Output
      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的更多相关文章

  1. 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 ...

  2. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  3. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  4. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  5. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  6. 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 ...

  7. 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 ...

  8. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  9. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

随机推荐

  1. es7.4.0集群部署

    其实主要是配置的变化,需要指定下master节点 cluster.name: prod-es node.name: node1 node.master: true node.data: true pa ...

  2. python学习之路 目录

    python Python基础-1 python由来 字符编码 注释 pyc文件 python变量 导入模块 获取用户输入 流程控制if while python基础-2 编码转换 pycharm 配 ...

  3. 1、Java语言概述与开发环境——Java程序运行机制

    Java语言是一种特殊的高级语言,它既有解释型语言的特性,也具有编译型语言的特征,因为Java要经过先编译后解释两个步骤. 一.高级语言的运行机制 计算机高级语言按程序的执行方式可以分为编译型和解释型 ...

  4. python中虚拟环境virtualenvwrapper的安装和使用

    虚拟环境为什么需要虚拟环境:       到目前为止,我们所有的第三方包安装都是直接通过 pip install xx 的方式进行安装的,这样安装会将那个包安装到你的系统级的 Python 环境中.但 ...

  5. 最长上升子序列(LIS) Medium2

    JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two ...

  6. HNUST-1681 机器人走格子(找规律)

    1681: 机器人走格子 时间限制: 1 Sec  内存限制: 128 MB提交: 244  解决: 58[提交][状态][讨论版] 题目描述 一个长X宽Y的棋盘,有XY个格子.将机器人放在某个格子中 ...

  7. TMS320F28335——SPI使用笔记

    一.SPI硬件接口 GPIO54    -------    SPISIMOA GPIO55    -------    SPISOMIA GPIO56    -------    SPCLK GPI ...

  8. php-redis的配置与使用

    从此处下载 https://codeload.github.com/phpredis/phpredis/zip/develop 也就php-redis的安装包,在zip格式,在windows下解压,将 ...

  9. 纯手写实现ajax分页功能

    前言 最近用到了这个功能,百度大半天,网上的不是有各种问题就是需要引入其他的插件,无奈,只能自己写,大致功能已经完成.前端页面用bootstrap做样式,分页功能用ajax实现,没用其他插件哦,只引入 ...

  10. [MyBatis]诡异的Invalid bound statement (not found)错误

    转自:https://blog.csdn.net/z69183787/article/details/48933481 自从开始使用Maven管理项目,最近在配置MyBatis的Mapper,在Ecl ...