Description

Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.

In this time, Timofey's elder brother, Dima reordered the cubes using the following rule. Suppose the cubes are numbered from 1 to n in their order. Dima performs several steps, on step i he reverses the segment of cubes from i-th to (n - i + 1)-th. He does this whilei ≤ n - i + 1.

After performing the operations Dima went away, being very proud of himself. When Timofey returned to his cubes, he understood that their order was changed. Help Timofey as fast as you can and save the holiday — restore the initial order of the cubes using information of their current location.

Input

The first line contains single integer n (1 ≤ n ≤ 2·105) — the number of cubes.

The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109), where ai is the number written on the i-th cube after Dima has changed their order.

Output

Print n integers, separated by spaces — the numbers written on the cubes in their initial order.

It can be shown that the answer is unique.

Examples
input
7
4 3 7 6 9 1 2
output
2 3 9 6 7 1 4
input
8
6 1 4 2 5 6 9 2
output
2 1 6 2 5 4 9 6
Note

Consider the first sample.

  1. At the begining row was [2, 3, 9, 6, 7, 1, 4].
  2. After first operation row was [4, 1, 7, 6, 9, 3, 2].
  3. After second operation row was [4, 3, 9, 6, 7, 1, 2].
  4. After third operation row was [4, 3, 7, 6, 9, 1, 2].
  5. At fourth operation we reverse just middle element, so nothing has changed. The final row is [4, 3, 7, 6, 9, 1, 2]. So the answer for this case is row [2, 3, 9, 6, 7, 1, 4].

题意:给我们交换后的数组,告诉我们交换规则1~n中(1,n交换,2,n-1交换....),然后是2~n-1中(2,n-1交换......),直到中间位置,问我们初始数组是怎么排列的

解法:偶数位置是不动的,奇数位置需要调换就好了

 #include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int b[];
int n;
//vector<int>q;
cin>>n;
int a[];
for(int i=; i<=n; i++)
{
cin>>a[i];
}
if(n%)
{
for(int i=;i<=n/;i++)
{
if(i&)
{
swap(a[i],a[n-i+]);
}
}
for(int i=;i<=n;i++)
{
cout<<a[i]<<" ";
}
}
else if(n!=&&n%==)
{
for(int i=;i<=n/;i++)
{
if(i&)
{
swap(a[i],a[n-i+]);
}
}
for(int i=;i<=n;i++)
{
cout<<a[i]<<" ";
}
}
else
{
cout<<a[]<<" "<<a[]<<endl;
}
return ;
}

Codeforces Round #395 (Div. 2) B的更多相关文章

  1. Codeforces Round #395 (Div. 2)(A.思维,B,水)

    A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:stan ...

  2. Codeforces Round #395 (Div. 2) D. Timofey and rectangles

    地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 s ...

  3. Codeforces Round #395 (Div. 2) C. Timofey and a tree

    地址:http://codeforces.com/contest/764/problem/C 题目: C. Timofey and a tree time limit per test 2 secon ...

  4. Codeforces Round #395 (Div. 2)B. Timofey and cubes

    地址:http://codeforces.com/contest/764/problem/B 题目: B. Timofey and cubes time limit per test 1 second ...

  5. Codeforces Round #395 (Div. 1)

    比赛链接:http://codeforces.com/contest/763 A题: #include <iostream> #include <cstdio> #includ ...

  6. Codeforces Round #395 (Div. 2)(未完)

    2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> ...

  7. Codeforces Round #395 (Div. 2)

    今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内  两个序列  n,2*n,3*n...... ...

  8. 【分类讨论】Codeforces Round #395 (Div. 2) D. Timofey and rectangles

    D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都 ...

  9. 【树形DP】Codeforces Round #395 (Div. 2) C. Timofey and a tree

    标题写的树形DP是瞎扯的. 先把1看作根. 预处理出f[i]表示以i为根的子树是什么颜色,如果是杂色的话,就是0. 然后从根节点开始转移,转移到某个子节点时,如果其子节点都是纯色,并且它上面的那一坨结 ...

  10. Codeforces Round #395 (Div. 2) C

    题意 : 给出一颗树 每个点都有一个颜色 选一个点作为根节点 使它的子树各自纯色 我想到了缩点后check直径 当<=3的时候可能有解 12必定有解 3的时候需要check直径中点的组成点里是否 ...

随机推荐

  1. Ajax_HTTP请求以及响应

    什么是HTTP请求? 就是从用户的浏览器端向服务器端发送请求 一个HTTP请求一般由四个部分组成 1.HTTP请求的方法或者动作,比如GET或者POST请求 2.请求的URL,也就是请求的地址 3.请 ...

  2. ajax返回页面停留跳转

    ajax返回数据后,页面停留跳转. 原理:利用匿名函数自动运行的特性和定时器来完成. (function(){ ; // 设置停留时间单位秒 var href =data.url; //设置跳转的ur ...

  3. 【bzoj4554】[Tjoi2016&Heoi2016]游戏

    现在问题有硬石头和软石头的限制 所以要对地图进行预处理 分行做,把有#隔开的*(x)形成联通块的存储下来. 分列作,把有#隔开的*(x)形成联通块的存储下来. 求出所有的行联通个数和列联通个数 作为二 ...

  4. ECMAScript学习笔记

    1. ECMAScript不存在块级作用域,因此在循环内部定义的变量,在循环外也是可以访问的 eg: var count =10; fpr(var i=0; i<count; i++){ ale ...

  5. ubuntu 本地和服务器scp文件传输

    安装 SSH(Secure Shell) 服务以提供远程管理服务 sudo apt-get install ssh SSH 远程登入 Ubuntu 机 ssh username@192.168.0.1 ...

  6. About "self"

    Class method can't refer derectly to instance variables. Within the body of  a class method, self re ...

  7. GPS常见故障

    当出现故障时,依据可能原因进行排查. 下表列举典型故障及调试方法 现象 root cause 检查 实验   GPS无法开启/无法搜星 软件配置错误 SW 相关配置(如GPIO等) 录制mobile ...

  8. LoadRunner使用动态链接库技术

    什么是动态库? 动态库一般又叫动态链接库英文为DLL,是Dynamic Link Library 的缩写形式,DLL是一个包含可由多个程序同时使用的代码和数据的库,DLL不是可执行文件.动态链接提供了 ...

  9. MFC之document与view实践总结

    Document/View是MFC的基石,负责程序数据的管理和显示,Doculent和Viewd的关系有一档一视,一档多视和多档多视,下面将分别对实现过程中的重点知识进行总结. 1. 视图的同步更新 ...

  10. 让ie支持css3的一些htc文件

    1. Dean Edwards的IE7.js (以及 IE8.js, IE9.js)这个玩意估计是试图让IE支持CSS3属性的鼻祖,还算蛮强大,就是性能开销较大,要解析很多文件脚本,给DOM添加大量的 ...