题目链接

假设始终可以找到一种状态使得值为0, 那么两个1之间需要隔n-2个数, 两个2之间需要隔n-3个数, 两个3之间隔n-4个数。 我们发现两个三可以放到两个1之间, 同理两个5放到两个3之间....这样就构造好了。

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, n, a) for(int i = a; i<n; i++)
#define fi first
#define se second
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-;
const int mod = 1e9+;
const int inf = ;
const int dir[][] = { {-, }, {, }, {, -}, {, } };
int a[];
int main()
{
int n;
cin>>n;
int l = , r = n, cnt = ;
while(r>l) {
a[l++] = cnt, a[r--] = cnt;
cnt+=;
}
l = n+, r = l+n-, cnt = ;
while(r>l) {
a[l++] = cnt, a[r--] = cnt;
cnt+=;
}
for(int i = ; i<=*n; i++) {
if(a[i])
printf("%d ", a[i]);
else
printf("%d ", n);
}
return ;
}

codeforces 622C. Optimal Number Permutation 构造的更多相关文章

  1. Educational Codeforces Round 7 D. Optimal Number Permutation 构造题

    D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...

  2. CodeForces 622D Optimal Number Permutation

    是一个简单构造题. 请观察公式: 绝对值里面的就是 |di-(n-i)|,即di与(n-i)的差值的绝对值. 事实上,对于任何n,我们都可以构造出来每一个i的di与(n-i)的差值为0. 换句话说,就 ...

  3. codeforces 622D D. Optimal Number Permutation(找规律)

    D. Optimal Number Permutation time limit per test 1 second memory limit per test 256 megabytes input ...

  4. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  5. [Codeforces 1214A]Optimal Currency Exchange(贪心)

    [Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的 ...

  6. Codeforces Round #275 (Div. 1)A. Diverse Permutation 构造

    Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 ht ...

  7. Codeforces Round #309 (Div. 1) B. Kyoya and Permutation 构造

    B. Kyoya and Permutation Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  8. Codeforces 804E The same permutation(构造)

    [题目链接] http://codeforces.com/contest/804/problem/E [题目大意] 给出一个1到n的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...

  9. Codeforces Round #350 (Div. 2) F. Restore a Number 模拟构造题

    F. Restore a Number   Vasya decided to pass a very large integer n to Kate. First, he wrote that num ...

随机推荐

  1. adb server is out of date.

    1:今天调试android的时候发现一个诡异的问题 C:\Users\xxxx>adb start-server adb server is out of date.  killing... A ...

  2. 获取第下一个兄弟元素 屏蔽浏览器的差异(nextElementsibling)

    //获取element下一个兄弟元素 function getNextElementSibling(element){ //能力检测 判断是否支持nextElementSibling if(eleme ...

  3. history.js 一个无刷新就可改变浏览器栏地址的插件(不依赖jquery)

    示例: http://browserstate.github.io/history.js/demo/     简介   HTML4有一些对浏览历史的前进后退API的支持如:   window.hist ...

  4. android UI-EditText的长度监听慎用TextWatcher

    在用户昵称的输入时,限定8个字符,本意是在输入超过8个时候,页面toast一个提示,就是下面的TextWatcher的监听,在afterTextChanged中处理. 原bug:huawei MT2- ...

  5. English - in the light of(按照,根据)与according to的区别是什么

    according to 表示as stated by 像陈述的那样 如According to Sarah they're not getting on very well at the momen ...

  6. DataSet和DataTable详解

    先构建一个结构与用户请求数据结构相同的DataTable,然后将用户的请求数据填充到构建好的DataTable中,最后将DataTable添加到DataSet中. DataTable,,DataCol ...

  7. spring schema自定义

    今天看了一下分布式服务框架的那本书,于是里面提到了spring schema的自定义,于是去简单的了解了一下 参考资源:spring schema扩展: http://www.yihaomen.com ...

  8. Web API (一)

    页面内容 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...

  9. font awesome使用笔记

    背景 今天将BS项目部署到IIS服务器上时.首次打开一个使用font awesome图标集的页面是加载非常慢. 于是果断按下F12查看具体页面的请求时常.除去其他异步数据的加载消耗时间以外.我居然看到 ...

  10. Android 仿360桌面小人

    首先自定义FloatsWindowView,用于显示动画小人. import android.annotation.SuppressLint; import android.content.Conte ...