Permutation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
Special Judge

Problem Description
A permutation p1,p2,...,pn of 1,2,...,n is called a lucky permutation if and only if pi≡0(mod|pi−pi2|) for i=3...n.

Now you need to construct a lucky permutation with a given n.

 
Input
The first line is the number of test cases.

For each test case, one single line contains a positive integer n(3≤n≤105).

 
Output
For each test case, output a single line with n numbers p1,p2,...,pn.

It is guaranteed that there exists at least one solution. And if there are different solutions, print any one of them.

 
Sample Input
1
6
 
Sample Output
1 3 2 6 4 5
 
Source
2017 ACM/ICPC 哈尔滨赛区网络赛——测试专用
 
 

题意就是给出的n,从1到n,满足条件pi≡0(mod|pi−pi2|) for i=3...n.

就是pi%(pi-pi-2)==0就可以。

一开始想的好麻烦,队友太强啦,直接%1就可以啦,只要要计算的两个数相差为1就可以。

看代码就知道了,后面的数顺序和逆序都无所谓的。

代码:

 #include<bits/stdc++.h>
using namespace std;
const int N=1e5+;
int a[N];
int main(){
int t,n;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
int h=,k=n;
for(int i=;i<=n;i+=)a[i]=h++;
for(int i=;i<=n;i+=)a[i]=k--;
for(int i=;i<=n;i++)
printf("%d ",a[i]);
printf("\n");
}
return ;
}

队友太厉害啦,%%%。

 
 
 
 

HDU6235-Permutation-水题-2017中国大学生程序设计竞赛-哈尔滨站-重现赛的更多相关文章

  1. HDU 6235.Permutation (2017中国大学生程序设计竞赛-哈尔滨站-重现赛)

    Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Tot ...

  2. HDU6237-A Simple Stone Game-找素因子(欧拉函数)-2017中国大学生程序设计竞赛-哈尔滨站-重现赛

    A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  3. HDU 6237.A Simple Stone Game-欧拉函数找素因子 (2017中国大学生程序设计竞赛-哈尔滨站-重现赛)

    A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  4. HDU 6273.Master of GCD-差分数组 (2017中国大学生程序设计竞赛-杭州站-重现赛(感谢浙江理工))

    Super-palindrome 题面地址:http://acm.hdu.edu.cn/downloads/CCPC2018-Hangzhou-ProblemSet.pdf 这道题是差分数组的题目,线 ...

  5. 2017中国大学生程序设计竞赛-哈尔滨站 Solution

    A - Palindrome 题意:给出一个字符串,找出其中有多少个子串满足one-half-palindromic 的定义 思路:其实就是找一个i, j  使得 以i为中轴的回文串长度和以j为中轴的 ...

  6. 2017中国大学生程序设计竞赛-哈尔滨站 A - Palindrome

    Palindrome Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Tota ...

  7. 【2017中国大学生程序设计竞赛-哈尔滨站】B - K-th Number

    原题: 题意: 给你一个长度为N的正整数组A,对于这个数组的所有子区间,若长度小于k则不管它,若长度大于等于k则取第k大放入数组B 问你B中第M大的数是谁 一眼序列分治,然而没思路 数据结构?能想到从 ...

  8. 2017中国大学生程序设计竞赛-哈尔滨站 H - A Simple Stone Game

    A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  9. 2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)

    Deleting Edges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

随机推荐

  1. Hibernate学习---单表查询

    我们都知道SQL是非常强大的,为什么这么说呢?相信学过数据库原理的同学们都深有体会,SQL语句变化无穷,好毫不夸张的说可以实现任意符合我们需要的数据库操作,既然前面讲到Hibernate非常强大,所以 ...

  2. 关于C++函数返回局部对象的详细分析

    以前一直挺好奇的,C++是怎么在函数内返回一个局部对象的.因为按照我之前的想法,函数返回一个基本类型的值是通过存放到ecx实现的(关于浮点不了解),但是局部对象又是比较大的,很明显不能使用寄存器作为通 ...

  3. 《Linux系统编程手册》读书笔记——第2章基本概念

    操作系统的核心--内核 内核的职责 进程调度:Linux属于抢占式多任务操作系统,多个进程可同时驻留于内存,且每个进程都能获得对CPU的使用权.哪些进程获得对CPU的使用,以及每个进程能使用多长时间 ...

  4. xamarin android alertdialog详解

    说明一下:学习xamarin android一段时间,准备写一些xamarin android相关的例子,alertdialog也是使用的非常多得空间之一,非常感谢鸟巢上的小猪,我也是看着他写的教程学 ...

  5. 树链剖分X2

    1.ZJOI树的统计 板子题 因为初始化没打改了几个小时 改到双腿软着出的机房(身体素质感人 #include<iostream> #include<cstdio> #incl ...

  6. 理解JavaScript原型

    Javascript原型总会给人产生一些困惑,无论是经验丰富的专家,还是作者自己也时常表现出对这个概念某些有限的理解,我认为这样的困惑在我们一开始接触原型时就已经产生了,它们常常和new.constr ...

  7. Vuejs实现列表选中效果

    //html <div id="app"> <ul><div>选择你最喜欢的爱好:</div> <li class=" ...

  8. js 数组API之forEach、map的用法

    forEach语法: arr.forEach(function(value, index, array){--}) 实例: // forEach ,,,,]; arr.forEach(function ...

  9. promise 和 async 的用法

    promise // 先构造一个 promise 函数 // resolve 和 reject 都是一个函数 // resolve 在成功时调用 // reject 在失败时调用 function p ...

  10. [补充资料] 手动搭建 Cloudera 集群

    本课主题 集群搭建 设置 Web 服务器 启动 ClouderManager 登入 Cloudera Manager 引言 这部份是一个补充资料,记录如何安装 Cloudera 服务器 集群搭建 查看 ...