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

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. java连接sqL2008 数据库实例

    package com.lzw; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSe ...

  2. (转) Name visibility

    Scopes Named entities, such as variables, functions, and compound types need to be declared before b ...

  3. codeforces 342D Xenia and Dominoes(状压dp+容斥)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud D. Xenia and Dominoes Xenia likes puzzles ...

  4. SSH 5W学习

    what SSH的英文全称为Secure Shell,是IETF(Internet Engineering Task Force)的Network Working Group所制定的一族协议,其目的是 ...

  5. JVM学习积累

    1. Java代码编译和执行的整个过程包含了三个重要的机制: Java源码编译机制 类加载机制 类执行机制 2. 关于Java源码编译机制 Java源码编译由以下三个过程组成: 分析和输入符号表 注解 ...

  6. HTML5_1

    2014,新年伊始,我不再是那个憧憬离开大学校园.过自由生活的傻丫头了.23岁,时间荏苒,差不多四分之一的人生已悄然逝去,大学生活差不多也快要画上句号了.工作.工作永远都是人生的一部分.曾想着随便找一 ...

  7. C++----练习--bool类型作为特别的int要区别对待

    1.程序源码: #include<iostream> int main() { ; int i=condition; std::cout<<i<<std::endl ...

  8. T-SQL 语法元素

    一.标识符 在T-SQL语言中,对SQLServer数据库及其数据对象(比如表.索引.视图.存储过程.触发器等)需要以名称来进行命名并加以区分,这些名称就称为标识符. 通常情况下,SQLServer数 ...

  9. Android EditText setOnClickListener事件 只有获取焦点才能响应 采用setOnTouchListener解决

    最近在学习Android开发,在编写程序的过程中,发现EditText setOnClickListener事件响应中,只有获取焦点的时候才会响应, 如当焦点在别的控件上时,只能先点击获取焦点,第二次 ...

  10. Linux系统编程(6)——文件系统

    计算机的文件系统是一种存储和组织计算机数据的方法,它使得对其访问和查找变得容易,文件系统使用文件和树形目录的抽象逻辑概念代替了硬盘和光盘等物理设备使用数据块的概念,用户使用文件系统来保存数据不必关心数 ...