Swap

There is a sequence of numbers of length nn, and each number in the sequence is different. There are two operations:

  1. Swap the first half and the last half of the sequence (if nn is odd, the middle number does not change)
  1. Swap all the numbers in the even position with the previous number (the position number starts from 11, and if⁡⁡ nn is odd, the last number does not change)

Both operations can be repeated innumerable times. Your task is to find out how many different sequences may appear (two sequences are different as long as the numbers in any one position are different).

Input

Each test file contains a single test case. In each test file:

The first line contains an integer nn, indicating the length of the sequence (1 \le n \le 10000)(1≤n≤10000).

The second line contains nn different numbers.

Output

Output the number of different sequences.

样例输入1复制

3
2 5 8

样例输出1复制

6

样例输入2复制

4
1 2 3 4

样例输出2复制

4

找规律,打个表就发现了。

打表代码也贴下面。

代码:

 //L-找规律
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+; int a[maxn]; int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
if(n>=&&n<=&&n!=){
printf("%d\n",n);
return ;
}
else if(n==){
printf("%d\n",n*);
return ;
}
if(n%==){
if((n/)%==){
printf("4\n");
}
else{
printf("%d\n",n);
}
}
else{
if((n-)%==){
printf("12\n");
}
else{
printf("%d\n",n*);
}
}
} /*
1
2
6
4
10
6
12
4
18
10
12
4
26
14
12
4
34
18
12
4
*/ /*
打表找规律
打表的代码 #include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1.0);
const int maxn=1e5+10; char a[maxn]; int main()
{
for(int k=1;k<=20;k++){
int n=k;
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++){
a[i]='a'+i-1;
}
int num=0;
int cnt=50;
map<string,int> mp;
string s;
while(cnt--){
for(int i=1;i<n;i+=2){
swap(a[i],a[i+1]);
}
s.clear();
for(int i=1;i<=n;i++){
s+=a[i];
}
if(mp[s]==0) num++,mp[s]=1;
int ret;
if(n%2==1) ret=n/2+1;
else ret=n/2;
for(int i=1;i<=n/2;i++){
swap(a[i],a[i+ret]);
}
s.clear();
for(int i=1;i<=n;i++){
s+=a[i];
}
if(mp[s]==0) num++,mp[s]=1;
}
cout<<num<<endl;
}
} */

计蒜客 39279.Swap-打表找规律 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest L.) 2019ICPC西安邀请赛现场赛重现赛的更多相关文章

  1. 计蒜客 39272.Tree-树链剖分(点权)+带修改区间异或和 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest E.) 2019ICPC西安邀请赛现场赛重现赛

    Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered  ...

  2. 计蒜客 39280.Travel-二分+最短路dijkstra-二分过程中保存结果,因为二分完最后的不一定是结果 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest M.) 2019ICPC西安邀请赛现场赛重现赛

    Travel There are nn planets in the MOT galaxy, and each planet has a unique number from 1 \sim n1∼n. ...

  3. 计蒜客 39270.Angel's Journey-简单的计算几何 ((The 2019 ACM-ICPC China Shannxi Provincial Programming Contest C.) 2019ICPC西安邀请赛现场赛重现赛

    Angel's Journey “Miyane!” This day Hana asks Miyako for help again. Hana plays the part of angel on ...

  4. 计蒜客 39268.Tasks-签到 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest A.) 2019ICPC西安邀请赛现场赛重现赛

    Tasks It's too late now, but you still have too much work to do. There are nn tasks on your list. Th ...

  5. 计蒜客31452 Supreme Number(找规律)

    A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...

  6. 计蒜客 28315.Excellent Engineers-线段树(单点更新、区间最值) (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 E)

    先写这几道题,比赛的时候有事就只签了个到. 题目传送门 E. Excellent Engineers 传送门 这个题的意思就是如果一个人的r1,r2,r3中的某一个比已存在的人中的小,就把这个人添加到 ...

  7. 计蒜客 成绩统计 (Hash表)

    链接 : Here! 思路 : 如果用 $STL$ 的 $map$ 或者是使用 $unordered\underline{}map$ 的话是会 $T$ 的, 所以得手写一个 $hash表$. 其实这个 ...

  8. 最短路+找规律 Samara University ACM ICPC 2016-2017 Quarterfinal Qualification Contest L. Right Build

    题目链接:http://codeforces.com/gym/101149/problem/L 题目大意:有n个点(其实是n+1个点,因为编号是0~n),m条有向边.起点是0,到a和b两个节点,所经过 ...

  9. 计蒜客 A1607 UVALive 8512 [ACM-ICPC 2017 Asia Xi'an]XOR

    ICPC官网题面假的,要下载PDF,点了提交还找不到结果在哪看(我没找到),用VJ交还直接return 0;也能AC 计蒜客题面 这个好 Time limit 3000 ms OS Linux 题目来 ...

随机推荐

  1. Spring boot java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver

    Spring boot 2.0.3 RELEASE 配置报错 java.lang.NoClassDefFoundError: org/springframework/boot/bind/Relaxed ...

  2. Windows 创建 Redis 和 zookeeper 系统服务

    Redis 启动 Redis start cmd /k "cd/d c:\Redis-x64-3.2.100\&&echo start Redis &&red ...

  3. Swagger Liunx环境搭建(亲测百分百可用)

    一.安装nodejs 下载编译好的nodejs安装包,下载地址: https://nodejs.org/dist/v10.10.0/ (作者下载的10.10.0,可根据自己需要下载不同版本) 将下载好 ...

  4. Docker02-重要概念

    目录 Docker简介 思考 Docker是什么 Docker 解决了什么问题 Docker 的优点 Docker的目的 Docker常用场景 虚拟化和Docker的对比 Docker的架构 Dock ...

  5. 【Docker】docker安装mysql

    一.下载镜像并运行容器 docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs ...

  6. GCC编译流程浅析

    GCC-GCC编译流程浅析 序言 对于大多数程序员而言,大家都知道gcc是什么,但是如果不接触到linux平台下的开发,鲜有人真正了解gcc的编译流程,因为windows+IDE的开发模式简直是一条龙 ...

  7. 如何利用python教程判断一个 IP 在不在线?

    假设今天老板给我们一个任务,让我们判断一下一个 IP 在不在线.我们随手用 python 写一个 ping IP 的代码: import os host = input('请输入要检测的 IP : ' ...

  8. Linux操作系统之更改启动菜单的背景图实战案例

    Linux操作系统之更改启动菜单的背景图实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.制作图像并上传到服务器 1>.使用window 10操作系统自带的画图工具 ...

  9. MySQL/MariaDB数据库的视图(VIEW)

     MySQL/MariaDB数据库的视图(VIEW) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.视图概述 1>.什么是视图 视图就是一个虚拟的表,保存有实表的查询结果 ...

  10. php将原数组倒序array_reverse()

    1.数组倒序排列 $arr = array(1,2,3); $arr = array_reverse($arr); print_r($arr);