C - pushpush(找规律水题)

 题目链接:https://atcoder.jp/contests/arc077/tasks/arc077_a

Problem Statement

You are given an integer sequence of length nn, a1,...,ana1,...,an. Let us consider performing the following nn operations on an empty sequence bb.

The ii-th operation is as follows:

  1. Append aiai to the end of bb.
  2. Reverse the order of the elements in bb.

Find the sequence bb obtained after these nn operations.

Constraints

  • 1≤n≤2×1051≤n≤2×105
  • 0≤ai≤1090≤ai≤109
  • nn and aiai are integers.

Input

Input is given from Standard Input in the following format:

nn
a1a1 a2a2 ...... anan

Output

Print nn integers in a line with spaces in between. The ii-th integer should be bibi.


Sample Input 1 Copy

Copy

4
1 2 3 4

Sample Output 1 Copy

Copy

4 2 1 3
  • After step 1 of the first operation, bb becomes: 11.
  • After step 2 of the first operation, bb becomes: 11.
  • After step 1 of the second operation, bb becomes: 1,21,2.
  • After step 2 of the second operation, bb becomes: 2,12,1.
  • After step 1 of the third operation, bb becomes: 2,1,32,1,3.
  • After step 2 of the third operation, bb becomes: 3,1,23,1,2.
  • After step 1 of the fourth operation, bb becomes: 3,1,2,43,1,2,4.
  • After step 2 of the fourth operation, bb becomes: 4,2,1,34,2,1,3.

Thus, the answer is 4 2 1 3.


Sample Input 2 Copy

Copy

3
1 2 3

Sample Output 2 Copy

Copy

3 1 2

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


Sample Input 3 Copy

Copy

1
1000000000

Sample Output 3 Copy

Copy

1000000000

Sample Input 4 Copy

Copy

6
0 6 7 6 7 0

Sample Output 4 Copy

Copy

0 6 6 0 7 7

代码:
 

#include<bits/stdc++.h>
using namespace std;
int a[200009];
int vis[200009];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
memset(vis,0,sizeof(vis));
        for(int i=n;i>0;i-=2)
        {
            cout<<a[i]<<" ";
            vis[i]=1;
        }
        for(int i=1;i<=n;i++)
        {
            if(vis[i]==0)
            {
                cout<<a[i]<<" ";
            }
        }


}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值