CCPC 2017 哈尔滨 F题
2017-12-22 16:48
225 查看
为什么开始做CCPC因为我突然发现了题目哈哈,绝对不是HDOJ的题目卡住了。
题目描述
A permutation p1, p2, … , pn of 1, 2, …, n is called a lucky permutation if and only if pi ≡ 0 (mod|pi - pi - 2|) for i = 3 … n. Now you need to construct a lucky permutation with a given n.
输入描述:
The first line is the number of test cases.
For each test case, one single line contains a positive integer n(3 ≤ n ≤ 105).
输出描述:
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.
只要输出一种只要找规律就好了。i只和i-2有关,满足条件有两种第一是倍数,第二相差1。所以这就很简单了啊。分两列,13579 246810 就行了。
题目描述
A permutation p1, p2, … , pn of 1, 2, …, n is called a lucky permutation if and only if pi ≡ 0 (mod|pi - pi - 2|) for i = 3 … n. Now you need to construct a lucky permutation with a given n.
输入描述:
The first line is the number of test cases.
For each test case, one single line contains a positive integer n(3 ≤ n ≤ 105).
输出描述:
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.
只要输出一种只要找规律就好了。i只和i-2有关,满足条件有两种第一是倍数,第二相差1。所以这就很简单了啊。分两列,13579 246810 就行了。
#include<bits/stdc++.h> #define max(a,b) a>b?a:b #define min(a,b) a<b?a:b using namespace std ; typedef long long ll; typedef unsigned long long ull; const ll MAX = 1005; int main(){ ll n,t; while(cin>>t){ while(t--){ cin>>n; int c = n%2+n/2; for(int i = 1 ; i < c ; i++) cout<<i<<" "<<c+i<<" "; if(n%2) cout<<c<<endl; else cout<<c<<" "<<n<<endl; } } return 0; }
相关文章推荐
- CCPC 2017 哈尔滨 H题
- 2017 CCPC 哈尔滨 A (hdu 6230) Palindrome (Manacher + BIT)
- CCPC 2017 哈尔滨赛区现场赛 比赛总结
- 2017 ccpc哈尔滨 A题 Palindrome
- 2017哈尔滨ccpc部分题解
- hdu6237-2017哈尔滨CCPC-质因子&贪心&暴力-A Simple Stone Game
- 2017CCPC哈尔滨 H:A Simple Stone Game
- 2017 CCPC 哈尔滨 M ( hdu 6242) Geometry Problem (随机化 + 三角形外心)
- 2017 CCPC 秦皇岛
- 2017 CCPC 哈尔滨站 HDU 6242
- 2017 CCPC Final小结 By JSB @ Reconquista
- 2017 ccpc秦皇岛L One-Dimensional Maze
- 2017 CCPC 秦皇岛 G Numbers 【贪心+大数+高精度】
- 2017 CCPC 秦皇岛
- 2017 CCPC-WFinal&&HDOJ 6030 Happy Necklace(矩阵快速幂)
- 2017哈尔滨ACM CCPC-final 总结
- 2017 CCPC 秦皇岛 & ZOJ 3981 - Balloon Robot 规律
- 2017 ccpc秦皇岛M Safest Buildings
- 2017 CCPC 秦皇岛站 M题题解 ZOJ 3993 Safest Buildings
- hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)