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. iOS开发数据库篇—SQLite常用的函数

    iOS开发数据库篇—SQLite常用的函数 一.简单说明 1.打开数据库 int sqlite3_open( const char *filename,   // 数据库的文件路径 sqlite3 * ...

  2. SVM学习(续)

    SVM的文章可以看:http://www.cnblogs.com/charlesblc/p/6193867.html 有写的最好的文章来自:http://www.blogjava.net/zhenan ...

  3. laravel开发微信公众号1 之基本配置

    需要用到的packagist:       https://github.com/overtrue/laravel-wechat  ( 目前最优雅的laravel微信sdk) 首先安装 compose ...

  4. SSH框架的配置

    ^_^阅读本文前请先浏览 : http://www.cnblogs.com/LiJinfu/p/5842890.html 步骤 : 一.编写web.xml配置文件 该文件路径在项目文件下的WebCon ...

  5. C#日常总结1

    Rows:行的集合: Columns:列的集合: Gridview:用来显示数据的表格{ //设置 AutoGenerateColumns="false":表示不允许自动产生列,列 ...

  6. 安装mongodb

    安装mongodb的时候遇到一些麻烦 首先将安装包下下来 安装的是windows版本的 将bin文件夹加入环境变量后通过mongod和mongo指令就可以进行操作,很方便 用指令mongod --db ...

  7. 第九章 企业项目开发--分布式缓存Redis(1)

    注意:本章代码将会建立在上一章的代码基础上,上一章链接<第八章 企业项目开发--分布式缓存memcached> 1.为什么用Redis 1.1.为什么用分布式缓存(或者说本地缓存存在的问题 ...

  8. JQuery Cross Domain

    frontend: first :add $.support.cors=true; in front of the Ajax code. seconde: add the crossDomain:tr ...

  9. sqlserver中创建包含事务的存储过程

    什么是事务     事务时包含1条或多条语句的逻辑单元.事务中的语句是一个整体,要么一起提交,要么一起撤销.事务在提交前可以回滚,一旦提交就不能撤销修改了,是永久性的修改.   为什么使用事务     ...

  10. jboss eap开启https协议

    1.使用 keytool -genkey -keystore chap8.keystore -storepass rmi+ssl -keypass rmi+ssl -keyalg RSA -alias ...