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. 453. Minimum Moves to Equal Array Elements

    Given anon-emptyinteger array of sizen, find the minimum number of moves required to make all array ...

  2. java中可变长参数

    ** * Created by Lenovo on 2017/12/10. * java中可变长参数 */ public class reflect04 { //m1有一个int类型的可比变长参数 / ...

  3. 搜索模式| 系列2——KMP算法

    给定一个文本txt [0..n-1]和一个模式pat [0..m-1],写一个搜索函数search(char pat [],char txt []),在txt中打印所有出现的pat [] [].可以假 ...

  4. Geode集群搭建

    Geode集群搭建 1.下载安装包 http://mirror.bit.edu.cn/apache/geode/1.2.0/ 2.安装解压后即可直接使用 apache-geode-1.2.0 3.进入 ...

  5. MySql监控优化

    MySQL监控   MySQL服务器硬件和OS(操作系统)调优:   1.有足够的物理内存,能将整个InnoDB文件加载到内存里 —— 如果访问的文件在内存里,而不是在磁盘上,InnoDB会快很多. ...

  6. Golang文件IO 一

    Golang文件IO 一 文件IO编程最基本.最常用的就属读写文件操作了.ioutil包实现了一些IO实用功能,其中就包括非常简捷.好用的文件读取功能. ioutil包有7个函数1个变量: var D ...

  7. flask 部署后并发测试

    部署后看下flask支持的并发,来个300并发看看,上代码 import threading, time, requests url = "http://www.baidu.com" ...

  8. jquery提供的插件无法删除cookie的解决办法

    之前使用jquery的cookie插件提供的 $.cookie("key",null)方法删除cookie,结果发现代码中的cookie一直无法删除,导致后面的种种问题. 经过各种 ...

  9. Windows上Python2与Python3共存

    首先安装好python2与python3版本 因为安装顺序的不同,所以系统默认的版本也不同.如果先安装的是python,那么系统默认的就是python2 如果根据需求需要使用不同的版本,可以使用py命 ...

  10. python pandas stack和unstack函数

    在用pandas进行数据重排时,经常用到stack和unstack两个函数.stack的意思是堆叠,堆积,unstack即"不要堆叠",我对两个函数是这样理解和区分的. 常见的数据 ...