Ural 1313 - Some Words about Sport
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[100][100], M; scanf("%d",&N); for(i = 0; i < N; i++) { for(j = 0; j < N; j++) { scanf("%d", &a[i][j]); } } t = 1; M = 2 * N - 2; printf("%d", a[0][0]); while(t <= M) { if(t <= N - 1) { for(j = 0; j <= t; j++) { printf(" %d",a[t - j][j]); } } else { for(j = t - (N - 1); j <= N - 1; j++) { printf(" %d", a[t - j][j]); } } t++; } printf("\n"); } int main() { solve(); return 0; }
作者:acutus
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· 开发者新选择:用DeepSeek实现Cursor级智能编程的免费方案
· 【译】.NET 升级助手现在支持升级到集中式包管理
· 独立开发经验谈:如何通过 Docker 让潜在客户快速体验你的系统
· Tinyfox 发生重大改版