Ural doctors worry about the health of their youth very much. Special investigations showed that a lot of clever students instead of playing football, skating or bicycling had participated in something like Programming Olympiads. Moreover, they call it sports programming! To sit near the monitor and think during 5 hours a day – is it a sport? To do it two times per year during the contests – it is more or less normal, but during the preparations to the nearest contest they spend several hours a week sitting at their computers! It would be possible to understand if they were some blockheads and dunces, but they are ones of the best students all over the world!
To save students from the harmful habit to sit at the computer for hours, Ural doctors has invented a fundamentally new monitor with diagonal trace of a beam in its electron-beam tube. Soon the winners of Ural Programming Championship would be awarded with such monitors. In the specially designed square monitor the electronic beam would scan the screen not horizontally but diagonally. The difference of the lengths of different diagonals causes such effects as non-uniform brightness, flashing and non-linear distortions. The terrible properties of such monitors would break of the habit of looking at the monitor for hours. There is a little problem: the majority of computer video cards generates the normal “rectangle” signal for monitor. So it is necessary to develop special adapter-program, which should transform the usual “rectangle” signal to the signal necessary for this kind of monitors. Program should be fast and reliable. That’s why the development of this program is entrusted to the participants of the Ural Championship for Sports Programming.

Input

The first input line contains the single integer N (1 ≤ N ≤ 100) – the number of pixels on the side of new square monitor. It is followed by N lines, each containing N positive integers not exceeding 100 divided by spaces. It is the image outputting by the usual video card (as you can see the color depth of new monitor is not so large – anyway usual programmer does not need more than 100 colors).

Output

You are to write the program that outputs the sequence for input into the new monitor. Pixels are numbered from the upper-left corner of the screen diagonally from left ot right and bottom-up. There is no need to explain details – look at the sample and you'll understand everything.

Sample

input output
4
1 3 6 10
2 5 9 13
4 8 12 15
7 11 14 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Problem Author: Idea - Stanislav Vasilyev, prepared by Stanislav Vasilyev and Alexander Klepinin Problem Source: VIII Collegiate Students Urals Programming Contest. Yekaterinburg, March 11-16, 2004
// Ural Problem 1313. Some Words about Sport
// Verdict: Accepted
// Submission Date: 20:50:20 14 Jan 2014
// Run Time: 0.031s
//
// 版权所有(C)acutus (mail: acutus@126.com)
// 博客地址:http://www.cnblogs.com/acutus/// [解题方法]
// 简单题,直接找矩阵规律即可 #include<stdio.h> void solve()
{
int i, t, j, N, a[][], M;
scanf("%d",&N);
for(i = ; i < N; i++) {
for(j = ; j < N; j++) {
scanf("%d", &a[i][j]);
}
}
t = ;
M = * N - ;
printf("%d", a[][]);
while(t <= M) {
if(t <= N - ) {
for(j = ; j <= t; j++) {
printf(" %d",a[t - j][j]);
}
} else {
for(j = t - (N - ); j <= N - ; j++) {
printf(" %d", a[t - j][j]);
}
}
t++;
}
printf("\n");
} int main()
{
solve();
return ;
}

Ural 1313 - Some Words about Sport的更多相关文章

  1. URAL 1779 F - The Great Team 构造

    F - The Great TeamTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  2. Ural Sport Programming Championship 2015

    Ural Sport Programming Championship 2015 A - The First Day at School 题目描述:给出课程安排,打印一个课程表. solution 暴 ...

  3. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  4. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  5. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  6. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  7. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  8. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

  9. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

随机推荐

  1. shell学习-读取输入

    功能:读取输入,打印:如果长度小于MINLEN,那么输出空格. #!/bin/bash # paragraph-space.sh # Insert a blank line between parag ...

  2. 64位系统未注册"MSDAORA.1"提供程序

    原因:如错误,64位系统未注册"MSDAORA.1"提供程序 解决:在IIS应用程序池中找到自己的网站,打开高级设置,设置“启用32位应用程序”为“True”即可. 另外还有其他解 ...

  3. ASP.net WebAPI 上传图片

    [HttpPost] public Task<Hashtable> ImgUpload() { // 检查是否是 multipart/form-data if (!Request.Cont ...

  4. ASCII码图

    图片转ASCII码图   效果图 基本思路 把图片每个像素点的信息拿出来,最重要的是拿到rgb的值 把每个像素点由rgb转成灰度图像,即0-255 给0-255分级,把每个等级的像素点转换成ascii ...

  5. MySQL FEDERATED 存储引擎

    MySQL中针对不同的功能需求提供了不同的存储引擎.所谓的存储引擎也就是MySQL下特定接口的具体实现. FEDERATED是其中一个专门针对远程数据库的实现.一般情况下在本地数据库中建表会在数据库目 ...

  6. java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp

    http://stackoverflow.com/questions/13269564/java-lang-classcastexception-oracle-sql-timestamp-cannot ...

  7. DropDownList控件学习

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  8. Lua学习笔记5:类及继承的实现

    -- Lua中类的实现 -------------------------------- 基类 ---------------------------- classBase = {x = 0,y = ...

  9. 解决shell脚本中 echo 怎么写入换行到文件

    測试环境:ubuntu12.04 LTS版本号 echo >> file.txt就可以, 这样的方法对于脚本开头是bash和sh效果都一样, 而echo -e >> file. ...

  10. js 字符串为空

    content.replace(/(^\s)|(\s$)/g, "")