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\) ...
随机推荐
- 解决因为Telnet没有启动导致FTP无法连接的问题
今天ytkah在其他电脑上想用ftp传点东西发现居然连接不上,查看了一下服务器安全组规则里的端口,也没有相关屏蔽.问了一下运维,他说可能是Telnet没有开启.就试着去看看有没问题.打开 控制面板 - ...
- RN无限轮播以及ScrollView的大小调节问题
如果你的ScrollView的大小是全屏,height不能用,这种情况需要给ScrollView添加一个容器View,然后调节容器View的大小 无限轮播这里我使用的是一个第三方的插件react-na ...
- 下载pywin32
下载pywin32 链接:sourceforge.net/projects/pywin32/files/ 1.找到一个pywin32的文件夹 2.下一级目录里面有多个文件夹. 3.打开Build222 ...
- shell进阶函数
函数的定义和用途 函数function是由若干条shell命令组成的语句块,实现shell代码的重用和模块化编程. 函数和shell程序的异同点 它与shell程序形式上是相似的,不同的是它不是一个单 ...
- Java Script的用途(简介)
1.可以用来写入HTML输出 <script> document.write("<h1>This is a heading</h1>");//标 ...
- vux 使用swiper 垂直滚动文字 报错[Intervention] Ignored...
[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example becaus ...
- Cartographer源码阅读(2):Node和MapBuilder对象
上文提到特别注意map_builder_bridge_.AddTrajectory(x,x),查看其中的代码.两点: 首先是map_builder_.AddTrajectoryBuilder(...) ...
- iot-dm异常日志
iot-dm 本机断网日志 2018-03-15 08:55:41,345 INFO com.inspur.iot.client.core.IotConnection Connection is be ...
- sklearn.svm.LinearSVC文档学习
https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html#sklearn.svm.LinearSVC 1 ...
- (转载)spring RestTemplate用法详解
前面介绍过spring的MVC结合不同的view显示不同的数据,如:结合json的view显示json.结合xml的view显示xml文档.那么这些数据除了在WebBrowser中用JavaScrip ...