题目链接:http://arc077.contest.atcoder.jp/tasks/arc077_a

Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

You are given an integer sequence of length na1,…,an. Let us consider performing the following n operations on an empty sequence b.

The i-th operation is as follows:

  1. Append ai to the end of b.
  2. Reverse the order of the elements in b.

Find the sequence b obtained after these n operations.

Constraints

  • 1≤n≤2×105
  • 0≤ai≤109
  • n and ai are integers.

Input

Input is given from Standard Input in the following format:

n
a1 a2 an

Output

Print n integers in a line with spaces in between. The i-th integer should be bi.


Sample Input 1

Copy
4
1 2 3 4

Sample Output 1

Copy
4 2 1 3
  • After step 1 of the first operation, b becomes: 1.
  • After step 2 of the first operation, b becomes: 1.
  • After step 1 of the second operation, b becomes: 1,2.
  • After step 2 of the second operation, b becomes: 2,1.
  • After step 1 of the third operation, b becomes: 2,1,3.
  • After step 2 of the third operation, b becomes: 3,1,2.
  • After step 1 of the fourth operation, b becomes: 3,1,2,4.
  • After step 2 of the fourth operation, b becomes: 4,2,1,3.

Thus, the answer is 4 2 1 3.


Sample Input 2

Copy
3
1 2 3

Sample Output 2

Copy
3 1 2

As shown above in Sample Output 1, b becomes 3,1,2 after step 2 of the third operation. Thus, the answer is 3 1 2.


Sample Input 3

Copy
1
1000000000

Sample Output 3

Copy
1000000000

Sample Input 4

Copy
6
0 6 7 6 7 0

Sample Output 4

Copy
0 6 6 0 7 7

题解:找规律

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
const int N=;
const int mod=1e9+;
int a[N];
int main()
{
std::ios::sync_with_stdio(false);
int n;
while(cin>>n){
for(int i=;i<=n;++i){
cin>>a[i];
}
if(n&){
cout<<a[n];
for(int i=n-;i>=;i-=)
cout<<" "<<a[i];
for(int i=;i<=n-;i+=)
cout<<" "<<a[i];
cout<<endl;
}else{
cout<<a[n];
for(int i=n-;i>=;i-=)
cout<<" "<<a[i];
for(int i=;i<=n-;i+=)
cout<<" "<<a[i];
cout<<endl;
}
}
return ;
}

AtCoder Regular Contest 077 C - pushpush的更多相关文章

  1. AtCoder Regular Contest 077 被虐记&题解

    直到\(7:58\)才知道今天\(8:00\)有\(AtCoder\)的菜鸡来写题解啦. C - pushpush 题目: 给定一个长为\(n\)的序列,第\(i\)次操作做如下的事 : 将\(a_i ...

  2. AtCoder Regular Contest 077 E - guruguru

    https://arc077.contest.atcoder.jp/tasks/arc077_c 有m个点围成一个圈,按顺时针编号为1到m,一开始可以固定一个位置x,每次操作可以往顺时针方向走一步或直 ...

  3. AtCoder Regular Contest 077 D - 11

    题目链接:http://arc077.contest.atcoder.jp/tasks/arc077_b Time limit : 2sec / Memory limit : 256MB Score ...

  4. AtCoder Regular Contest 077

    跟身在国外的Marathon-fan一起打的比赛,虽然最后没出F但还是涨分了. C - pushpush 题意:n次操作,每次往一个序列后面塞数,然后把整个序列翻转. #include<cstd ...

  5. AtCoder Regular Contest 077 E - guruguru 线性函数 前缀和

    题目链接 题意 灯有\(m\)个亮度等级,\(1,2,...,m\),有两种按钮: 每次将亮度等级\(+1\),如\(1\rightarrow 2,2\rightarrow 3,...,m-1\rig ...

  6. 【arc077f】AtCoder Regular Contest 077 F - SS

    题意 给你一个形如"SS"的串S,以及一个函数\(f(x)\),\(x\)是一个形如"SS"的字符串,\(f(x)\)也是一个形如"SS"的 ...

  7. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  8. AtCoder Regular Contest 094 (ARC094) CDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...

  9. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

随机推荐

  1. dedecms首页去掉index.html怎么设置

    很多网友用IIS服务器建站,反映说dedecms首页默认多了一个/index.html,一般是没有这个后缀的,直接就**.com,那么如何将dedecms首页去掉index.html呢?很简单,服务器 ...

  2. Python递归优化方法

    递归栈溢出 Python的递归调用栈的深度有限制,默认深度为998,可以通过sys.getrecursionlimit()查看. 针对递归栈溢出,我们可以将默认深度设置为大一些,这样不会报错,但是再大 ...

  3. 数据库---mysql内置功能

    一.视图 简介: 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用.使用视图我们可以把查询过 ...

  4. IE8.0如何关闭启用内存保护帮助减少联机攻击?

    默认情况下,该选项卡是灰色的(表示用户不能直接修改),win7电脑可以通过“以管理员身份”运行 IE 来放开该功能,但个别电脑即便用这种方法仍无法解决,此时,您可以试试如下方法: 1.在“运行”框中输 ...

  5. 20165236实验一 Java开发环境的熟悉

    课程:Java       姓名:郭金涛      学号:20165236 实验日期:2018/04/01        指导老师:娄嘉鹏 实验名称:Java开发环境的熟悉 实验要求: 1. 建立“自 ...

  6. 前端框架之Vue(5)-条件渲染

    v-if 在字符串模板中,比如 Django Template语法中,我们得像这样写一个条件块: <!-- Handlebars 模板 --> {%if 1%} <h1>Yes ...

  7. Trie树(转:http://blog.csdn.net/arhaiyun/article/details/11913501)

    Trie 树, 又称字典树,单词查找树.它来源于retrieval(检索)中取中间四个字符构成(读音同try).用于存储大量的字符串以便支持快速模式匹配.主要应用在信息检索领域. Trie 有三种结构 ...

  8. PHP实现装饰器

    参考:https://www.cnblogs.com/onephp/p/6108940.html ●装饰器模式(Decorator),可以动态地添加修改类的功能 ●一个类提供了一项功能,如果要在修改并 ...

  9. Java Selenium - 元素操作 (四)

    四,弹出框 京东购物车为例 , 点击‘删除’ 或者‘移到我的关注’ ,就会弹出下面这个框框,练吧: (其实这也不是常规的弹出框,二是div css前端技术做的效果,本想做个Alert的案例,实在不好找 ...

  10. android apk打包编译好的so

    加入so到apk有多种方法 1.build.gradle(Module)中android子项中加入以下代码,并将so放到到armeai/armeabi-v7a 子目录下 sourceSets { ma ...