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. eclipse + maven 搭建springMVC+Spring+mybatis 系统

    首先需要下载maven 安装maven插件.自行百度. 1: 创建maven系统 http://huxiaoheihei.iteye.com/blog/1766986 2:添加pom依赖: pom.x ...

  2. mac 启动apache + php

    一.启动Apache 在终端里输入命令,启动 Apache: sudo apachectl start 关闭 Apache: sudo apachectl stop 重启 Apache:sudo ap ...

  3. 理解RxJava线程模型

    RxJava作为目前一款超火的框架,它便捷的线程切换一直被人们津津乐道,本文从源码的角度,来对RxJava的线程模型做一次深入理解.(注:本文的多处代码都并非原本的RxJava的源码,而是用来说明逻辑 ...

  4. netbean快捷键

    1.Application应用程序的参数args的设置,在Build->Set Main Projects Configuration 2.程序运行快捷键F6 3.@Deprecated 4.代 ...

  5. logistic回归模型

    一.模型简介 线性回归默认因变量为连续变量,而实际分析中,有时候会遇到因变量为分类变量的情况,例如阴性阳性.性别.血型等.此时如果还使用前面介绍的线性回归模型进行拟合的话,会出现问题,以二分类变量为例 ...

  6. Source Insight简介及下载破解

    对于长期混迹于.net平台的开发人员来说,研究C源码不是很常见,但是有时候我们不得不涉及c的研究,因为许多优秀的开源软件是用C/C++写就.查看C源码的利器除了VS外,还有另一个,那就是Source ...

  7. hdu 1532(最大流)

    Drainage Ditches Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. LINQ to Entities 不支持 LINQ 表达式节点类型“Invoke”(笔记)

    今天使用使用动态查询的时候出现出现错误“LINQ to Entities 不支持 LINQ 表达式节点类型‘Invoke’.”,代码如下: IQueryable<CUSTOMER> que ...

  9. iOS开发网络篇—搭建本地服务器

    iOS开发网络篇—搭建本地服务器 一.简单说明 说明:提前下载好相关软件,且安装目录最好安装在全英文路径下.如果路径有中文名,那么可能会出现一些莫名其妙的问题. 提示:提前准备好的软件 apache- ...

  10. 转: jdbc连接数据库需要注意和出错的地方

    * 1.数据库登录模式不能只使用windows登录模式,要采取混合模式登录, * 并记住相应的密码和账户: * 2.连接数据库后一定要记得关闭资源,否则就会造成资源浪费. * 关闭的时候也要注意顺序, ...