A. Candy Bags
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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.

Examples
input
2
output
1 4
2 3
Note

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.

这个太水了 从两边按要求输出就好

附AC代码:

 #include<bits/stdc++.h>
using namespace std; int main(){
int n;
cin>>n;
int l=,r=n*n;
for(int i=;i<n;i++){
int temp=n;
while(temp--){
cout<<l++<<" "<<r--<<" ";
temp--;
}
cout<<endl;
}
return ;
}

F - Candy Bags的更多相关文章

  1. Candy Bags

    读懂了题就会发现这是个超级大水题 Description Gerald has n younger brothers and their number happens to be even. One ...

  2. A. Candy Bags

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

  3. 334A Candy Bags

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

  4. @atcoder - Japanese Student Championship 2019 Qualification - F@ Candy Retribution

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 请找到满足以下条件的长度为 N 的非负整数序列 A1, A2, ...

  5. codeforces A. Candy Bags 解题报告

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

  6. codeforces 334A - Candy Bags

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

  7. Candy Distribution

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

  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. CodeForces Round 194 Div2

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

随机推荐

  1. Mathematica 表达式求值

    表达式是变量之间的运算关系.表达式求值就是对变量赋值并运算出结果的过程. 针对于Mathematica中的表达式.有两种方法获得其值. 一是对对应的变量直接赋值.这样对应的表达式在调用时便会直接运算得 ...

  2. javaweb 中的过滤器 包装器

    过滤器要做的事情: 请求过滤器:完毕安全检查,又一次格式化请求首部或体.建立请求审计或日志 响应过滤器:     压缩响应流,追加或改动响应流创建一个全然不同的响应. 过滤器和servlet三个相似地 ...

  3. DevExpress2011控件教程)编辑控件(comboBox,AspxCheckBox) 范例1

    DevExpress2011控件教程)编辑控件(comboBox,AspxCheckBox) 范例1 AspxCheckBox 是一个检查编辑控件去展示特殊条件是否关闭或者打开.它一般会展示Yes/N ...

  4. 【C语言天天练(九)】动态内存分配

    引言:数组的元素存储于内存中连续的位置上.当一个数组被声明时.它所须要的内存在编译时就被分配. 可是,我们能够使用动态内存分配在执行时为它分配内存. 一块内存的生命周期能够分为四个阶段:分配.初始化. ...

  5. 如何在List集合中去重

    众所周知List集合中的元素是有序的,但是List中的元素同样是可以重复的,那么我们应该怎么在List集合中去重呢? 方法一: 对于方法一而言,这也许是一个小窍门.利用的是Set集合中不允许出现重复的 ...

  6. Json——使用Json jar包实现Json字符串与Java对象或集合之间的互相转换

    总结一下利用Json相关jar包实现Java对象和集合与Json字符串之间的互相转换: 1.创建的User类: package com.ghj.packageofdomain; public clas ...

  7. 释放SQL Server占用的内存 .Net 读取xml UrlReWriter 在web.config中简单的配置

    释放SQL Server占用的内存   由于Sql Server对于系统内存的管理策略是有多少占多少,除非系统内存不够用了(大约到剩余内存为4M左右),Sql Server才会释放一点点内存.所以很多 ...

  8. 【算法编程】找出仅仅出现一次的数-singleNumber

    题目意思: 一个数值数组中,大部分的数值出现两次,仅仅有一个数值仅仅出现过一次,求编程求出该数字. 要求,时间复杂度为线性,空间复杂度为O(1). 解题思路: 1.先排序.后查找. 因为排序的最快时间 ...

  9. ListView 实现带有Filpper效果的左右滑动删除 Item

    ListView 实现带有Filpper效果的左右滑动删除 Item  的实现最基本的方法还是 对 Listview 的继承重写 .然后是在删除过程中加入 TranslateAnimation 滑动事 ...

  10. 【前端JS】radio 可单选可点击取消选中

    普通情况下 radio 单选框仅仅能实现多选一的效果,可是一旦选择当中一个后,这个单选框就不可点击取消其选中状态了.这样的功能在某些业务环境下并不适用.有时我们既须要单选框的多选一效果.也须要复选框的 ...