HDU6235-Permutation-水题-2017中国大学生程序设计竞赛-哈尔滨站-重现赛
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
Now you need to construct a lucky permutation with a given n.
For each test case, one single line contains a positive integer n(3≤n≤105).
It is guaranteed that there exists at least one solution. And if there are different solutions, print any one of them.
题意就是给出的n,从1到n,满足条件pi≡0(mod|pi−pi−2|) 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中国大学生程序设计竞赛-哈尔滨站-重现赛的更多相关文章
- HDU 6235.Permutation (2017中国大学生程序设计竞赛-哈尔滨站-重现赛)
Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
- HDU6237-A Simple Stone Game-找素因子(欧拉函数)-2017中国大学生程序设计竞赛-哈尔滨站-重现赛
A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- 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 ...
- HDU 6273.Master of GCD-差分数组 (2017中国大学生程序设计竞赛-杭州站-重现赛(感谢浙江理工))
Super-palindrome 题面地址:http://acm.hdu.edu.cn/downloads/CCPC2018-Hangzhou-ProblemSet.pdf 这道题是差分数组的题目,线 ...
- 2017中国大学生程序设计竞赛-哈尔滨站 Solution
A - Palindrome 题意:给出一个字符串,找出其中有多少个子串满足one-half-palindromic 的定义 思路:其实就是找一个i, j 使得 以i为中轴的回文串长度和以j为中轴的 ...
- 2017中国大学生程序设计竞赛-哈尔滨站 A - Palindrome
Palindrome Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tota ...
- 【2017中国大学生程序设计竞赛-哈尔滨站】B - K-th Number
原题: 题意: 给你一个长度为N的正整数组A,对于这个数组的所有子区间,若长度小于k则不管它,若长度大于等于k则取第k大放入数组B 问你B中第M大的数是谁 一眼序列分治,然而没思路 数据结构?能想到从 ...
- 2017中国大学生程序设计竞赛-哈尔滨站 H - A Simple Stone Game
A Simple Stone Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- 2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)
Deleting Edges Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
随机推荐
- iOS 控制器的跳转、页面四个方向的跳转
指定滑动方向的跳转 CATransition *transition = [CATransition animation]; transition.duration = 0.3f; transitio ...
- Linux第三节整理 、增删改查、用户管理
帮助+基本文件管理+用户管理 1.怎么查看命令帮助 ls --help man ls :查看命令/man 5 file:查看配置文件 2.基本文件管理,通过{查,建,删,改} 四个维度介绍了不同的命令 ...
- grep 与 find 简单命令
在使用linux的时候,经常会用到查找文件或者查找文本,下面介绍两个命令. grep 使用方法: // 在当前目录下递归查找class字符串 grep "string" -r . ...
- css样式清零及常用类
css样式清零及常用类 @charset "utf-8"; /*CSS Reset*/ /*"微软雅黑","\5FAE\8F6F\96C5\9ED1& ...
- Mac下持久化路由配置
缘由 mac 下有个小命令,networksetup,之前电脑装了IKEv2 的VPN,每天能正常FQ,由于所有流量都走了VPN隧道,导致了公司内部的其它网络无法访问得到,必须每次的来回拨VPN,断V ...
- Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics state
在调用ggplpt2包画图时,出现错误 Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics ...
- display:inline-block引发的间隙思考
一.导火线 没错,总有一类属性在助你轻松寻得捷径的同时,也可为你增添烦劳,比如本文的主谋display:inline-block.众前端们所诸知,其作用是将对象呈递为内联对象,但是对象的内容作为块对象 ...
- ABP .Net Core 日志组件集成使用NLog
一.说明 NLog介绍和使用说明官网:http://nlog-project.org/ NLog和Log4net对比:https://www.cnblogs.com/qinjin/p/5134982. ...
- 各类模块的粗略总结(time,re,os,sys,序列化,pickle,shelve.#!json )
***collections 扩展数据类型*** ***re 正则相关操作 正则 匹配字符串*** ***time 时间相关 三种格式:时间戳,格式化时间(字符串),时间元组(结构化时间).***`` ...
- PHP动态图像处理
相关代码见:https://www.github.com/lozybean/learn_www/ 目录 1. 画布管理: imagecreate():创建一个基于调色板的画布,指定画布的长.宽 ...