zoukankan      html  css  js  c++  java
  • Ural 1313

    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

    inputoutput
    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("
    ");
    }
    
    int main()
    {
        solve();
        return 0;
    }
    作者:acutus
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    Azure 中 Linux 虚拟机的大小
    排查在 Azure 中创建、重启 Linux VM 或调整其大小时发生的分配故障
    如何在 Azure 中的 Linux 经典虚拟机上设置终结点
    针对通过 SSH 连接到 Azure Linux VM 时发生的失败、错误或被拒绝问题进行故障排除
    Linux 内核超时导致虚拟机无法正常启动
    Java并发编程(十三)同步容器类
    可以开发着玩一下的web项目
    org.tmatesoft.svn.core.SVNCancelException: svn: E200015: authentication canc
    FastDFS单机搭建以及java客户端Demo
    做前端(单纯页面和js)遇到的问题辑录(一)
  • 原文地址:https://www.cnblogs.com/acutus/p/3519946.html
Copyright © 2011-2022 走看看