CodeForces - 764B Timofey and cubes

这个题其实压根不用读题,看样例猜反而更简便。

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 while i ≤ 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.

At the begining row was [2, 3, 9, 6, 7, 1, 4].
After first operation row was [4, 1, 7, 6, 9, 3, 2].
After second operation row was [4, 3, 9, 6, 7, 1, 2].
After third operation row was [4, 3, 7, 6, 9, 1, 2].
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].

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#define N 100100
#define INF 0x3f3f3f3f
using namespace std;
int a[200100];
int main()
{int n,i;while(scanf("%d",&n)!=EOF){for(i=1;i<=n;i++){scanf("%d",&a[i]);}for(i=1;i<=n/2;i=i+2){swap(a[i],a[n-i+1]);}for(i=1;i<=n;i++){printf("%d ",a[i]);}printf("\n");}return 0;
}

CodeForces - 764B Timofey and cubes相关推荐

  1. 【CodeForces - 764B 】Timofey and cubes (模拟)

    题干: Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents ...

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

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

  3. (Incomplete) Codeforces #395 (Div 1 + Div 2)

    A. Taymyr is calling you 数据比较小,可以枚举每一次call的时间i*n, 然后检查 (i*n) % m 是否为0.如果为0,则答案加一.这种方法不需要想太多也不需要写太多. ...

  4. Codeforces Round #297 (Div. 2)E. Anya and Cubes 折半搜索

    Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec  Memory Limit: 512 MB Submit: xxx  ...

  5. Codeforces Round #702 C. Sum of Cubes

    解法:暴力 题目大意:给定一个x,求是否存在两个数使得 a*a*a + b*b*b = x. 思路:如果用双层for枚举,数据量一定会导致超时.所以可以通过枚举a,同时通过已经知道的x,来求出b,这样 ...

  6. 【CodeForces - 764D】Timofey and rectangles (四色定理 + 找规律 + 构造)

    题干: One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane ...

  7. ☆【CodeForces - 764C】Timofey and a tree (思维题,树的性质)

    题干: Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After tha ...

  8. CodeForces 257B Playing Cubes :两人轮流向已有序列后面放红蓝木块,一人想使相邻颜色相同多一人想不想同颜色多,最后得分? :博弈+思维...

    对比代码量,好大的思维量== 其实对于第二个拿相同的木块分的人,他当前放与上一个木块相同最优 对于第一个想拿不同木块分的人,他放与上一块木块不同颜色最优 第一个人放多的颜色木块更优= 至于为什么? & ...

  9. CodeForces 679B Bear and Tower of Cubes

    $dfs$,贪心. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> # ...

最新文章

  1. c语言作业 统计成绩,C语言作业 输入多名学生3门课程成绩,并统计成绩的平均分和总分,并根据总分输出名次。...
  2. python代码大全表解释-python操作列表的函数使用代码详解
  3. NSIS:超级轻量皮肤SkinH
  4. hibernate annotation注解 columnDefinition用法
  5. 分布式机器学习_京东出来的java工程师,竟然不知道分布式、高并发、多线程的区别?...
  6. Ubuntu平台 Qt 5.x 安装方法
  7. php 值不进行解码,无法解码PHP中的JSON值
  8. 万物皆可文本时代来临?如何搞定NLP最强模型GPT
  9. redis接口的二次封装
  10. linux下编译ios,为iOS安装OpenCV
  11. 自考数据结构和数据结构导论_我跳过大学自学数据科学
  12. 服务消费和负载(Feign)
  13. LinkedHashMap 底层分析
  14. 【NeurIPS2020】之预训练语言模型压缩
  15. 山西最新五大姓氏排名发布,排名第一的是王,第二的竟是……
  16. Windows使用阿里云RAM访问控制API实现自建DDNS动态域名解析
  17. 虚拟实习项目技术架构mal总结
  18. eclipse 重命名文件、移动文件、删除等操作时出现.svntmp文件
  19. 大学计算机课程学情分析,大学计算机基础课程教学内容调查分析.doc
  20. BUUCTF ------findkey

热门文章

  1. 三人表决电路——Verilog HDL语言
  2. 51 单片机实战教程(14 外围芯片驱动程序之LTC1658芯片驱动)
  3. 计算机视觉 国际著名研究机构
  4. 杂谈---令人抓狂的数据库行级锁问题
  5. WebUI——领导驾驶舱
  6. 一句话证明:费马大定理
  7. 彼岸夏花(一个爱与救赎的凄美故事)
  8. The Preliminary Contest for ICPC Asia Xuzhou 2019 - C Buy Watermelon | 读题
  9. 普通话水平测试软件怎么样,求测试普通话标准的软件?6款普通话软件推荐
  10. 老男孩之猛龙过江电影高清版迅雷下载