AtCoder Regular Contest 077 C - pushpush
题目链接: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 n, a1,…,an. Let us consider performing the following n operations on an empty sequence b.
The i-th operation is as follows:
- Append ai to the end of b.
- 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
4
1 2 3 4
Sample Output 1
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
3
1 2 3
Sample Output 2
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
1
1000000000
Sample Output 3
1000000000
Sample Input 4
6
0 6 7 6 7 0
Sample Output 4
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的更多相关文章
- AtCoder Regular Contest 077 被虐记&题解
直到\(7:58\)才知道今天\(8:00\)有\(AtCoder\)的菜鸡来写题解啦. C - pushpush 题目: 给定一个长为\(n\)的序列,第\(i\)次操作做如下的事 : 将\(a_i ...
- AtCoder Regular Contest 077 E - guruguru
https://arc077.contest.atcoder.jp/tasks/arc077_c 有m个点围成一个圈,按顺时针编号为1到m,一开始可以固定一个位置x,每次操作可以往顺时针方向走一步或直 ...
- AtCoder Regular Contest 077 D - 11
题目链接:http://arc077.contest.atcoder.jp/tasks/arc077_b Time limit : 2sec / Memory limit : 256MB Score ...
- AtCoder Regular Contest 077
跟身在国外的Marathon-fan一起打的比赛,虽然最后没出F但还是涨分了. C - pushpush 题意:n次操作,每次往一个序列后面塞数,然后把整个序列翻转. #include<cstd ...
- AtCoder Regular Contest 077 E - guruguru 线性函数 前缀和
题目链接 题意 灯有\(m\)个亮度等级,\(1,2,...,m\),有两种按钮: 每次将亮度等级\(+1\),如\(1\rightarrow 2,2\rightarrow 3,...,m-1\rig ...
- 【arc077f】AtCoder Regular Contest 077 F - SS
题意 给你一个形如"SS"的串S,以及一个函数\(f(x)\),\(x\)是一个形如"SS"的字符串,\(f(x)\)也是一个形如"SS"的 ...
- AtCoder Regular Contest 061
AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...
- AtCoder Regular Contest 094 (ARC094) CDE题解
原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...
- AtCoder Regular Contest 092
AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...
随机推荐
- 帝国cms文章页调用当前文章URL如何操作?
前面我们讨论过dedecms文章页调用地址(当前文章URL)如何操作,作为同台竞技的帝国cms也能在文章页调用当前文章URL吗?答案是肯定的!那就随ytkah一起来探索一下吧 帝国cms模板是在后台直 ...
- 执行hadoop自带的WordCount实例
hadoop 自带的WordCount实例可以统计一批文本文件中各单词出现的次数.下面介绍如何执行WordCount实例. 1.启动hadoop [root@hadoop ~]# start-all. ...
- .NET 三层框架
1.三层架构 三层架构(3-tier architecture) 通常意义上的三层架构就是将整个业务应用划分为:表现层(Presentation layer).业务逻辑层(Business Logic ...
- VS2008生成数据库连接字串
在写WEB程序的时候~通常需要在Web.config文件的<connectionStrings>节点上写数据库的链接字符串,因为是一串字符代码我们常常需要写在固定的文本里便于下次使用,其实 ...
- cube-ui中弹窗
if (!this.surname) { this.$createDialog({ type: "alert", icon: "cubeic-close", s ...
- Html-根据不同的分辨率设置不同的背景图片
@media only screen and (min-width: 1024px) //当分辨率width >= 1024px 时使用1.jpg作为背景图片 { ...
- 版本控制之GitHub亲手实验总结
使用Git的基本方式是:第一种,在remote端创建一个repository,clone到本地,然后在本地把已有文件添加进来/在本地clone的目录下创建新文件,再add 提交等纳入git版本 ...
- PHP 类名::class含义
自 PHP 5.5 起,关键词 class 也可用于类名的解析. 使用 ClassName::class 可以获取一个字符串,包含了类 ClassName 的完全限定名称.这对使用了命名空间的类尤其有 ...
- js快速排序算法解析
数组的快速排序算法,和并归排序步骤基本类似. 都是先拆分,后合并.并归排序是:拆分容易,合并难. 快速排序是:拆分难,合并容易 要理解快速排序,首先要理解拆分逻辑 要素:找一个基准点,通过操作使得数列 ...
- js 的date的format时间,获取当前时间,前一天的日期
Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + ...