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. 关于cors 跨域的一些问题

    system.webServer节点写配置 <httpProtocol> <customHeaders> <add name="Access-Control-A ...

  2. docker--docker compose 编排工具

    11 docker compose 编排工具 11.1 docker compose 介绍 根据前面所学的知识可知,想要使用Docker部署应用,就要先在应用中编写Dockerfile 文件来构建镜像 ...

  3. JS中值类型和引用类型

    一.值类型 例子: var a=10; var b=a; a=20; console.log(b); 例子中,将a的值赋给了b,b=10,然后改变a的值不会影响b的值,a和b是独立的两份,互不影响. ...

  4. HDU - 1845 Jimmy’s Assignment (二分匹配)

    Description Jimmy is studying Advanced Graph Algorithms at his university. His most recent assignmen ...

  5. 剑指offer 打印从1到最大的n位数

    题目描述: 输入数字n,按顺序打印出从1到最大的n位十进制数.比如输入3,则打印出1.2.3一直到最大的3位数999. 分析:注意不能直接输入最大的n位十进制数,因为可能属于大数,这个数无法用int或 ...

  6. mysql,oracle,sql server数据库默认的端口号,端口号可以为负数吗?以及常用协议所对应的缺省端口号

    mysql,oracle,sql server数据库默认的端口号? mysql:3306 Oracle:1521 sql server:1433 端口号可以为负吗? 不可以,端口号都有范围的,0~65 ...

  7. 理解PHP面向对象三大特性

    一.封装性 目的:保护类里面的数据,让类更安全, protected和private只能在类中或子类访问,通过public提供有限的接口供外部访问,封装是控制访问,而不是拒绝访问 封装关键字:publ ...

  8. ThinkPHP无法打开或点击不了Trace的问题

    首先先确认是否打开了Trace配置项,ThinkPHP3.*为'SHOW_PAGE_TRACE'=>true,ThinkPHP5.*为'app_trace'=>true. 如果已经确认开启 ...

  9. 切入点表达式execution()

    用于描述方法 [掌握] 语法:execution(修饰符 返回值 包.类.方法名(参数) throws异常) 修饰符,一般省略 public                公共方法 *         ...

  10. vs2013 找不到帮助 help查看器

    我手贱把help查看器卸载了,打开帮助提示找不到帮助. 不想把vs重装,打开ios镜像,加载,cmd进入 到packages\Help 执行msiexec /i help3_vs_net.msi vs ...