读懂了题就会发现这是个超级大水题

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

Input
2
Output
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的更多相关文章

  1. A. Candy Bags

    A. Candy Bags http://codeforces.com/problemset/problem/334/A   time limit per test 1 second memory l ...

  2. F - Candy Bags

    A. Candy Bags time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. 334A Candy Bags

    A. Candy Bags time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  4. codeforces A. Candy Bags 解题报告

    题目链接:http://codeforces.com/contest/334/problem/A 题意:有n个人,将1-n袋(第 i  袋共有 i  颗糖果,1<= i  <=n)所有的糖 ...

  5. codeforces 334A - Candy Bags

    忘了是偶数了,在纸上画奇数画了半天... #include<cstdio> #include<cstring> #include<cstdlib> #include ...

  6. Candy Distribution

    Kids like candies, so much that they start beating each other if the candies are not fairly distribu ...

  7. CodeForces Round 194 Div2

    A. Candy Bagstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputs ...

  8. 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 ...

  9. [LeetCode] Candy 分糖果问题

    There are N children standing in a line. Each child is assigned a rating value. You are giving candi ...

随机推荐

  1. 数据存储: sqlite,coredata plist 归档

    sql 语句  结构化查询语言 通用数据库操作语言1.创建数据库create database 1407EDB2.删除数据库drop database 1407EDB3.备份use master ex ...

  2. appStore应用发布流程

    原文转自: http://blog.sina.com.cn/s/blog_68661bd801019uzd.html       首先确定帐号是否能发布, https://developer.appl ...

  3. C#如何解决对ListView控件更新以及更新时界面闪烁问题

    第一个问题:如何更新ListView控件内容 很多时候运行窗体程序时,由于程序中使用了多线程加之操作不当,所以在对控件操作时会出现下面这样的异常:   这是因为我们在窗体中添加的控件都有属于自己的线程 ...

  4. uva 1597 Searching the Web

    The word "search engine" may not be strange to you. Generally speaking, a search engine se ...

  5. mysql创建存储过程

    -- 创建CREATE PROCEDURE proDelAccountById(IN in_accountid int) BEGIN -- 执行sql预计 END -- 调用 ; CALL proDe ...

  6. HTTP之I/O模型图MPM详细解析

    高度模块化:DSO MPM:多路处理模块      prefork-->一个主进程+多个工作进程,每个工作进程处理多个请求      worker-->一个主进程+多个工作进程,每个工作进 ...

  7. 场景2 nginx 错误日志格式:

    nginx 错误日志格式: 2016/09/01 11:23:36 [error] 28388#0: *14549 open() "/var/www/zjzc-web-frontEnd/im ...

  8. 一个C#多线程的工作队列

    多线程添加元素到队列中,队列根据绑定 的事件进行自动处理,可以设置WorkSequential属性来实现对队列处理的单线程(严格顺序处理)或者多线程处理(循序出队,但是 多线程处理,不保证对队列元素的 ...

  9. Combination Sum II 解答

    Question Given a collection of candidate numbers (C) and a target number (T), find all unique combin ...

  10. Mac 下纯lua(二)

    Lua库 基本函数 assert(v,[,message]) 当v时false时,返回message assert(money >0,"error -1001"); coll ...