A. Candy Bagstime limit per test
1 second
Memory limit per test
256 megabytes
Input
Standard input
Output
Standard output
Gerald hasNYounger brothers and their number happens to be even. One day he boughtN2 candy
Bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integerKFrom 1N2 he
Has exactly one bagKCandies.
Help him giveNBags of candies to each brother so that all brothers got the same number of candies.
Input
The single line contains a single integerN(NIs
Even, 2 bytes ≤ averageNLimit ≤ limit 100)-the number of Gerald's brothers.
Output
Let's assume that Gerald indexes his brothers with numbers from 1N.
You need to printNLines, onI-Th line printNIntegers
-The numbers of candies in the bags forI-Th brother. Naturally, all these numbers shoshould be distinct and be within limits from 1N2.
You can print the numbers in the lines in any order.
It is guaranteed that the solution exists at the given limits.
Sample test (s) input
2
Output
1 42 3
I am very stupid. I am abused every time I do it. It seems that I am no longer ashamed. Every time I feel like a visitor when I brush cf, I did not know anything, so I opened this topic. I don't want to read this topic. It's all an idiot question. This is a reminder for myself. The topic was held for n days, I haven't written any questions yet. I hope this is a good start. The following code is used:
#include <cstdio>#include <algorithm>using namespace std;int N, n;int main() { scanf ("%d", &N); n = N*N; for (int i = 0; i < N; i++) { for (int p = 1; p <= N/2; p++) { printf ("%d %d ", i*(N/2)+p, n-(i*(N/2)+p)+1); } printf ("\n"); } return 0;}