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

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. (转) Friendship and inheritance

    原地址: http://www.cplusplus.com/doc/tutorial/inheritance/ Friend functions In principle, private and p ...

  2. stl学习之字符串

    其实string也是stl里面的内容,记录几点自己不常用的内容 1.at方法(比[]会判断是否越位) 2. int copy(char *s, int n, int pos=0) const; 把当前 ...

  3. 【mysql】1206 SQLSTATE: HY000 (ER_LOCK_TABLE_FULL) 问题

    最近在做一个项目,其中一需求是:部分数据库中的数据需要定时删除掉(满足一定条件,比如7天前的数据都不保留) 最初的执行方法: 使用Quartz定时执行数据库操作,进行数据删除,数据库操作使用delet ...

  4. MySQL行级锁、表级锁、页级锁详细介绍

    原文链接:http://www.jb51.net/article/50047.htm 页级:引擎 BDB.表级:引擎 MyISAM , 理解为锁住整个表,可以同时读,写不行行级:引擎 INNODB , ...

  5. [C++程序设计]用指针变量作函数参数接收数组地址

    #include <iostream> using namespace std; void select_sort(int *p, int n) { int i, j, k; ; i &l ...

  6. ububru下 redmine安装教程

    1.安装之前确认你已经安装好了mysql 2.连接mysql创建数据库 mysql -u root –p CREATE DATABASE redmine CHARACTER SET utf8; CRE ...

  7. shell练习--批量创建账号

    #!/bin/bash #By spinestars #-- #cksum5位数获取方法,可能有重复 #pd="user`head -200 /dev/urandom | cksum | h ...

  8. SED&AWK

    SED   1.sed是流编辑器(stream editor)缩写,作用主要是文本替换 命令格式:sed ‘s/pattern/replace_string/' file或者cat file | se ...

  9. ubuntu14.04 安装搜狗输入法

    (1)下载链接 http://pinyin.sogou.com/linux/ (2)清除fcitx $sudo apt-get purge fcitx* (3)使用deb安装工具gdebi,这个工具能 ...

  10. poj 1129 Channel Allocation

    http://poj.org/problem?id=1129 import java.util.*; import java.math.*; public class Main { public st ...