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

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. UVA11401Triangle Counting(简单计数)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 题目意思:从1,2,3,……,n中选出3个不同的整数使其构成一个三角形,有多少种方 ...

  2. (a*b)%c 问题

    给你两个数__int64 类型的整数 a ,b,c.问你,(a*b)%c的值是多少??我们知道: (a*b)%c = ((a%c)*(b%c))%c .不过即使这样做,在c很大的情况下,(a%c)*( ...

  3. Linux下VMWare虚拟机的使用技巧

    使用技巧: 1.虚拟机安装文件:vm-workstation-full-8.0.3-703057.x86_64.bundle,./vm-workstation-full-8.0.3-703057.x8 ...

  4. bootstrap data- jquery .data

    jquery官网对.data函数描述是:在匹配元素上存储任意相关数据 或 返回匹配的元素集合中的第一个元素的给定名称的数据存储的值. 存储键值(key/value): $("body&quo ...

  5. HTML5简单入门系列(三)

    前言 本篇介绍HTML5支持的Web存储(Web Storage)和HTML 5 应用程序缓存. 客户端存储数据介绍 HTML5 提供了两种在客户端存储数据的新方法: localStorage - 没 ...

  6. ActionSupport.getText()方法 以及 js中:<s:text name="" />

    下面略述com.opensymphony.xwork2.ActionSupport.getText()方法 public String getText(String aTextName) 说明:Get ...

  7. eclipse 使用mvn模块化开发

    1.创建maven父工程步骤:new-->other-->选择maven project-->next-->勾选create a simple project-->nex ...

  8. wordpress教程之文章页single.php获取当前文章所属分类

    之所以要发这篇文章,是因为这个方法适用于: WP默认文章分类 手动添加的自定文章分类 插件(custom post type ui)添加的自定义文章分类(含taxonomy) 方法目的:在文章模板中, ...

  9. MongoDB insert performance rapidly dropping

    http://dba.stackexchange.com/questions/65554/mongodb-insert-performance-rapidly-dropping http://www. ...

  10. SQL Server索引设计 <第五篇>

    SQL Server索引的设计主要考虑因素如下: 检查WHERE条件和连接条件列: 使用窄索引: 检查列的选择性: 检查列的数据类型: 考虑列顺序: 考虑索引类型(聚集索引OR非聚集索引): 一.检查 ...