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. golang几种post请求方式

    get请求 get请求可以直接http.Get方法,非常简单. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 func httpGet() {     resp, err := h ...

  2. Go -- 如何使用gcore工具获取一个core文件而不重启应用?

    问题: 当调试一个程序的时候,理想状态是不重启应用程序就获取core文件. 解决: gcore命令可以使用下面步骤来获取core文件: 1. 确认gdb软件包已经被正确安装. 2. 使用调试参数编译程 ...

  3. android开发教程之使用线程实现视图平滑滚动示例 改

    package com.melonsapp.messenger.ui.popupuser; import android.os.Handler; import android.view.View; i ...

  4. Linux索引节点(Inode:no space for device)用满导致的一次故障

    问题描写叙述 在storm測试环境集群上上nimbus和supervisor自己主动挂调.重新启动时显示no space for device,也不能创建,加入文件及文件夹,df -h查看 ilesy ...

  5. ALERT日志中常见监听相关报错之三:ORA-609 TNS-12537 and TNS-12547 or TNS-12170 TNS-12535错误的排查

    1.11G中ALERT日志中有报错ORA-609 TNS-12537 and TNS-12547 or TNS-12170  12170, 'TNS-12535等问题的解决方法: Troublesho ...

  6. MergeLinklist

    写了一个合并有序链表,代码有点纠结啊.涉及到指针就是麻烦,DS课曹老师课件说linklist是DS的难点. . . 假设数组就非常easy了.链表就要小心. 里面遇到的一些情况.第一.最好是先确定l1 ...

  7. google protocol buffer的原理和使用(一)

    一.简单的介绍      Protocol buffers是一个用来序列化结构化数据的技术,支持多种语言诸如C++.Java以及Python语言.能够使用该技术来持久化数据或者序列化成网络传输的数据. ...

  8. 使用Swift作为Glance后端存储

    原文链接 http://thornelabs.net/2014/08/03/use-openstack-swift-as-a-backend-store-for-glance.html By defa ...

  9. OpenStack源码系列---nova-compute

    nova-compute运行的节点为计算节点,虚拟机运行于计算节点上.例如对于创建虚拟机请求,nova-api接收到客户端请求后,经过nova-scheduler调度器调度,再将请求发送给某个选定的n ...

  10. spring test---測试SpringMvc初识

    如今越来越多人使用SpringMvc来开发系统,在开发中可定须要对后台url地址请求測试,而且返回预期的结果! Spring提供的測试类MockMvc来进行url地址请求測试,使用方方式: packa ...