Candy Bags
读懂了题就会发现这是个超级大水题
Description
Gerald has n younger brothers and their number happens to be even. One day he bought n2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n2 he has exactly one bag with k candies.
Help him give n bags of candies to each brother so that all brothers got the same number of candies.
Input
The single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.
Output
Let's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n2. You can print the numbers in the lines in any order.
It is guaranteed that the solution exists at the given limits.
Sample Input
2
1 4
2 3
Hint
The sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.
#include<iostream>
#include<cstring>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
int N;
int a[]; scanf("%d",&N);
int l=;
int r=N*N; while(l<r)
{
cout<<l<<" "<<r<<endl;
l++;
r--;
}
}
Candy Bags的更多相关文章
- A. Candy Bags
A. Candy Bags http://codeforces.com/problemset/problem/334/A time limit per test 1 second memory l ...
- F - Candy Bags
A. Candy Bags time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 334A Candy Bags
A. Candy Bags time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces A. Candy Bags 解题报告
题目链接:http://codeforces.com/contest/334/problem/A 题意:有n个人,将1-n袋(第 i 袋共有 i 颗糖果,1<= i <=n)所有的糖 ...
- codeforces 334A - Candy Bags
忘了是偶数了,在纸上画奇数画了半天... #include<cstdio> #include<cstring> #include<cstdlib> #include ...
- Candy Distribution
Kids like candies, so much that they start beating each other if the candies are not fairly distribu ...
- CodeForces Round 194 Div2
A. Candy Bagstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputs ...
- Codeforces Round #194 (Div.1 + Div. 2)
A. Candy Bags 总糖果数\(\frac{n^2(n^2+1)}{2}\),所以每人的数量为\(\frac{n}{2}(n^2+1)\) \(n\)是偶数. B. Eight Point S ...
- [LeetCode] Candy 分糖果问题
There are N children standing in a line. Each child is assigned a rating value. You are giving candi ...
随机推荐
- 关于iOS9之后的loadViewIfNeeded
iOS9之前 有些时候因为需要手动调用loadview 但是有风险,系统不再调用viewDidLoad 所以手动调用loadview是错误的 iOS9之后出现了loadViewIfNeeded解决了这 ...
- PHP函数参数的引用传递和值传递
函数的参数传递有两种方式 1,值传递 常见的 test($param) 方式就是值传递,在函数内部修改$param,不会影响外部变量$param的值 2,引用传递 参数是引用传递的方式,此时函数内部 ...
- ERP行业推荐参考书籍
1 书名:<ERP 理论.方法与实践> 作者: 周玉清等编著 出版社:电子工业出版社 简介:本书全面介绍了ERP的基本原理和处理逻辑,以大量篇幅讨论了ERP的计划功能,特别是主生产计划功能 ...
- mysql create routine 权限的一些说明
1.如果用户有create routine 权限那么他就可以创建procedure | function . 2.如果用户创建了procedure | function 那么mysql 会自动赋予它对 ...
- Azure File文件共享(6):使用Python开发
Azure文件共享服务提供了多种方式的访问接口,包括Powershell,.Net, Java, Python等等,本章主要介绍如何使用Python来访问Azure File存储. 关于Python环 ...
- 玩sdr的朋友们,在rtl_tcp时,记得调整rtl_AGC和tuner_AGC啊
我在rtl_tcp时没有调整这个,结果怎么也听不到声音啊 还有就是在搞rtl_tcp时,一定要网速跟得上,我用无线网络时就碰到了这个问题,声音总是一直断续着,郁闷死
- 8051_asm.uew
/L20"8051 Assembly" AASM_LANG Line Comment = ; Nocase String Chars = ' File Extensions = S ...
- YY语音从4.0版本开始是基于Qt的开发过程,以及碰到的问题
作者:姚冬链接:http://www.zhihu.com/question/21359230/answer/20127715来源:知乎著作权归作者所有,转载请联系作者获得授权. YY语音从4.0版本开 ...
- Windows XP SP3中远程桌面实现多用户登陆
Windows XP SP3配置为支持多用户远程桌面连接,注意:此多用户远程桌面连接必须是不同的用户登录,不能像Windows server 2003那样,同一个用户可以同时登录,只能登陆2个不同用户 ...
- JSON数据解析——jsoncpp的使用
版权所有,转载请注明:http://blog.sina.com.cn/u/1978765352 由于工作中需要用到JSON数据,所以解析JSON数据就成了一个非常重要的工作内容. 其实用C++解析数据 ...