URAL 1319. Hotel
来源:互联网 发布:程序员网上接项目 编辑:程序博客网 时间:2024/06/06 13:25
1319. Hotel
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
— You programmers are lucky! You don't have to deal with these terrible people – designers… This story happened with me not so long ago. We had an order from a company building a new hotel. One day they brought a sketch to our workshop. They said that THIS was invented by a very cool designer. They said they had paid heaps of money for THIS. So, THIS had to be built. In general, THIS was not a very complex thing. It was just a square set of shelves where a porter puts guests' mail. Usual hotels have usual stands with shelves for this purpose. But this cool designer had turned everything upside down! To be more precise, not exactly upside down, but upon a corner. Moreover, the cells should be numbered from the right to the left, from the top to the bottom, looking at THIS, staying on its corner, of course. Tell me please, how can the master attach the labels with numbers to THIS? He will look on the shelves, staying normally on its side, you know. He will get tangled on the fourth label already! I will get tangled on the seventh, myself… Actually one should make such designers to label the shelves themselves.
— Oh! You are the cool programmer, I know. Couldn’t you help me? I need just a printout of the table with an arrangement of the labels in the cells. But not in such way as THIS will hang on the wall, but as THIS stands on the table of my workshop. Yes, I understand that you are busy, but you are busy every time! Preparations to the Ural Championship, tests, solutions… So what? If you can’t do it yourself – entrust your competitors with this task. They are the best programmers all over the world, aren’t they? I don’t believe that they couldn’t print the desired table having the size of the square! I would never believe it! So… Excellent! I will take the desired printout away after the contest.
Input
The input consists of the only one integer N (1 ≤ N ≤ 100), which is the size of the square.
Output
You are to write a program that outputs the table of numbers, as they would be arranged when THIS would stand in the workshop. The label with number 1 should be in the upper right corner and other numbers should be arranged along the diagonals from the top to the bottom. The label with the last number (N*N) should be in the lower left corner.
Sample
3
4 2 17 5 39 8 6
啥也不说了,贴代码堵脑洞。。。
#include<bits/stdc++.h>using namespace std;int a[110][110];int n;int main(){ while(~scanf("%d",&n)) { int vis=1; for(int j=n;j>0;j--) { int fx=1,fy=j; a[fx++][fy++]=vis++; while(fx<=n&&fy<=n) { a[fx++][fy++]=vis++; } } for(int i=2;i<=n;i++) { int fx=i,fy=1; a[fx++][fy++]=vis++; while(fx<=n&&fy<=n) { a[fx++][fy++]=vis++; } } for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) printf("%d ",a[i][j]); cout<<endl; } } return 0;}
0 0
- URAL 1319. Hotel
- URAL 1319. Hotel (模拟)
- timus 1319. Hotel URAL 解题报告
- [timus] 1319. Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- URAL
- 【ural】
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- _DataStructure_C_Impl:广义表的扩展线性链表存储
- 查看MySQL编码格式指令
- js 判断输入都年份是不是闰年
- 找出现次数最多的数-Ignatius and the Princess IV
- HDU-OJ-1017 A Mathematical Curiosity-整数对
- URAL 1319. Hotel
- 安卓实现登陆
- mac 下面如何安装brew
- 基督徒的工作观
- hpuoj 1697 找句子
- Android 蓝牙4.0 Bluetooth BLE 写数据(修改BLE设备的属性)
- 关于 Java 程序员的一些入门级面试题
- POM
- ssh登陆提示"Host key verification failed."的解决方法