codeforces194a
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的更多相关文章
随机推荐
- Linux Shell 批量更换文件名或后缀名
把下列所有.c的文件名修改为.cc rename .c .cc *.c
- 关于JS的数据类型的一些见解
关于js里的数据类型这块,说下个人对它的一些见地 js中的数据类型可以归类两类, 简单数据类型:string,number,boolean,null,undefined 复杂数据类型:object 其 ...
- C++中虚析构函数的作用
我们知道,用C++开发的时候,用来做基类的类的析构函数一般都是虚函数.可是,为什么要这样做呢?下面用一个小例子来说明: 有下面的两个类: class ClxBase { public: ...
- git@Osc初识
加油! 参考博客:http://www.cnblogs.com/lpshou/archive/2013/07/18/3199243.html 今天尝试了下git@osc的项目导入,基本算是入门了git ...
- 关于tomcat会在url末尾自动追加斜杠(/)
今天,突然发现一个问题, 比如我的请求路径为 http://ip:port/my_project/myapp, 在浏览器中敲入这个地址,然后会显示 http://ip:port/my_project ...
- 《大道至简》之第一章:编程的精义读后感(JAVA伪代码)
——大道至简之编程的精义读后感(JAVA伪代码) import.java.大道至简.*; import.java.愚公移山.*; public class YuGongYiShan{ 愚公 = {项目 ...
- 关于电脑安装多个版本JDK后使用时的切换
描述:刚到新公司,自己安装了jdk1.7和开发工具myeclipse10,但是由于公司项目的需要(具体原因不详细描述了),需要使用myeclipse6.5和jdk1.6.于是在切换jdk1.7和jdk ...
- JQuery 对 Select option 的操作
下拉框: <select id="selectID" > <option value="1">1</option& ...
- ShopNC小实例
shopnc 之模式: shopnc一般的url访问为:http://localhost/shopnc1/admin/index.php?act=sui&op=hello Controller ...
- 一些常用的方法(1)--去除DataTable中的重复数据
private DataTable Display(DataTable dtSource) { DataTable dtTemp = dtSource.Copy() ...