CF334A.Candy Bags

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Gerald has n younger brothers and their number happens to be even. One day he bought _n_2 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 _n_2 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.

杰拉尔德有 nn 个弟弟,且 nn 恰好为偶数。一天,他买了 n2n^2 袋糖果。其中一袋有 1 颗糖,一袋有 2 颗糖,一袋有 3 颗糖,依此类推。事实上,对每个从 11 到 n2n^2 的整数 kk,他恰好有一袋含 kk 颗糖的糖果袋。

请帮他将 nn 袋糖果分给每位弟弟,使得每位弟弟得到的糖果总数相等。

输入格式

The single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.

单行包含一个整数 nn(nn 为偶数,2 ≤ n ≤ 1002 \leq n \leq 100)—— 表示杰拉尔德的兄弟数量。

输出格式

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 _n_2. You can print the numbers in the lines in any order.

It is guaranteed that the solution exists at the given limits.

假设杰拉尔德用从 11 到 nn 的数字为其兄弟编号。你需要输出 nn 行,其中第 ii 行包含 nn 个整数——即第 ii 位兄弟所拥有的各袋糖果的数量。显然,所有这些数字必须互不相同,且均在 11 到 n2n^2 的范围内。每行中的数字顺序可以任意。

在给定的限制条件下,保证存在解。

输入输出样例

  • 输入#1

    2

    输出#1

    1 4
    2 3

说明/提示

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.

示例展示了杰拉尔德有两个兄弟时的操作。此时,他的袋子中分别装有 1、2、3 和 4 颗糖果。他可以将装有 1 颗和 4 颗糖果的袋子分给一个兄弟,将装有 2 颗和 3 颗糖果的袋子分给另一个兄弟。

输入解题思路,AI测评打分。不知道怎么写?

首页