link:http://codeforces.com/contest/334/problem/A

很有意思的一道构造题。发现CF上经常出这种不难但是很不错的构造题。

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
int main(void)
{
int n;
while (~scanf("%d",&n))
for (int i=;i<=n*n/;++i)
{
for (int j=;j<=n/;++j)
{
printf("%d %d ",i,n*n-i+);
++i;
}
i--;
printf("\n");
}
return ;
}

o(╯□╰)o

官方解题报告上面写的很明白

1  n^2

2  n^2-1

..  ..

n^2/2  n^2/2+1

然后这就是n^2/2组,每一组的和都相同。n^2/2/(n/2) = n组,所以我们只需要从这n^2/2组里面选择n/2组就满足了一个解,这样,恰好可以选出n组来。

codeforces194a的更多相关文章

随机推荐

  1. UITableView优化的方法

    使用不透明视图. 不透明的视图可以极大地提高渲染的速度.因此如非必要,可以将table cell及其子视图的opaque属性设为YES(默认值). 其中的特例包括背景色,它的alpha值应该为1(例如 ...

  2. 跨站脚本 XSS<一:介绍>

    *XSS 利用的是用户对指定网站的信任,CSRF 利用的是网站对用户网页浏览器的信任 跨站脚本(Cross-site scripting,通常简称为XSS)是一种网站应用程序的安全漏洞攻击,是代码注入 ...

  3. Android之垂直显示TextView

    Android之垂直显示TextView 1因为界面需求原因,需要TextView垂直显示,话不多说,看代码,我也是搜的例子,在此感谢写这个例子的大神,在此做个笔记和分享给大家 2.用到了自定义控件的 ...

  4. Android Studio UML 插件 PlantUML 使用语法

    活动标签(activity label)以冒号开始,以分号结束. 文本格式支持creole wiki语法. 活动默认安装它们定义的顺序就行连接. @startuml :Hello world; :Th ...

  5. 《浅谈磁盘控制器驱动》,磁盘控制器驱动答疑解惑![2012.1.29完结]by skyfree

    <浅谈磁盘控制器驱动>,磁盘控制器驱动答疑解惑![2012.1.29完结]  https://www.itiankong.net/thread-178655-1-1.html Skyfre ...

  6. oracle表空间不足相关问题解决办法

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  7. Shell 教程

    Shell 是一个用C语言编写的程序,它是用户使用Linux的桥梁.Shell既是一种命令语言,又是一种程序设计语言. Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操 ...

  8. C# 判断字符是否中文还是英文

    private static bool IsHanZi(string ch) { byte[] byte_len = System.Text.Encoding.Default.GetBytes(ch) ...

  9. SAP物料批次管理配置及操作手册(轉載)

    这个有待学习 业务说明需要先熟悉基本的物料管理(MM).生产计划管理(PP).销售与分销管理(SD)的相关知识.在化工.制药.快消.汽车零部件等行业,为了进行质量的跟踪,往往需要使用批次管理来监控质量 ...

  10. C#窗体 LISTVIEW

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...