题目链接:

# Name 补题状态
A
已补 
B
已补
C
已补
D  
E  

A:Memory and Crow

There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure:

  • The crow sets ai initially 0.
  • The crow then adds bi to ai, subtracts bi + 1, adds the bi + 2 number, and so on until the n'th number. Thus, ai = bi - bi + 1 + bi + 2 - bi + 3....

Memory gives you the values a1, a2, ..., an, and he now wants you to find the initial numbers b1, b2, ..., bn written in the row? Can you do it?

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of integers written in the row.

The next line contains n, the i'th of which is ai ( - 109 ≤ ai ≤ 109) — the value of the i'th number.

Output

Print n integers corresponding to the sequence b1, b2, ..., bn. It's guaranteed that the answer is unique and fits in 32-bit integer type.

Examples

input
5
6 -4 8 -2 3
output
2 4 6 1 3 
input
5
3 -2 -1 5 6
output
1 -3 4 11 6 

Note

In the first sample test, the crows report the numbers 6, - 4, 8, - 2, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6 = 2 - 4 + 6 - 1 + 3, and  - 4 = 4 - 6 + 1 - 3.

In the second sample test, the sequence 1,  - 3, 4, 11, 6 satisfies the reports. For example, 5 = 11 - 6 and 6 = 6.

题意描述:

大致意思就是,输入n输入n个整数,求挨着的两个整数和,然后最后一个整数单独输出。//因博主没过四级:题意是看样例看出来的,具体不确定

#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
#define ll long long
int main() {
ll n, a[100010];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i]; if (i > 0)cout << a[i] + a[i - 1] << " ";
}
cout << a[n - 1] << "\n";
return 0;
}

  

B. Memory and Trident

Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:

  • An 'L' indicates he should move one unit left.
  • An 'R' indicates he should move one unit right.
  • A 'U' indicates he should move one unit up.
  • A 'D' indicates he should move one unit down.

But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.

Input

The first and only line contains the string s (1 ≤ |s| ≤ 100 000) — the instructions Memory is given.

Output

If there is a string satisfying the conditions, output a single integer — the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.

Examples

input
RRU
output
-1
input
UDUR
output
1
input
RUUR
output
2

Note

In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.

In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin.

题目大意:

输入一串字符串,包含:U(上),D(下),L(左),R(右),你在原点,按照字符串走,然后你可以随意修改里边任意一个字符改成你想要的,求最少修改多少次可以走回到原点,会不到的话输出-1。

1 》如果字符串长度是奇数的话肯定走不回原点。

2 》一个D就能抵消一个U,一个L就能抵消一个R,求抵消后的   sum= abs(sl - sr) + abs(su - sd),向右走一个,只需要修改第二个向左走就行,上下同理,所以结果为sum/2

#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main() {
string a;
int sl = 0, sr = 0, su = 0, sd = 0, sum = 0;
//sl:'L'个数 sr:'R'个数 su:'U'个数 sd:'D'个数
cin >> a;
if (a.size() & 1)cout << "-1\n";
else {
for (int i = 0; i < a.size(); i++) {
if (a[i] == 'L')sl++;
else if (a[i] == 'R')sr++;
else if (a[i] == 'U')su++;
else sd++;
}
sum = abs(sl - sr) + abs(su - sd);
cout << sum / 2 << "\n";
}
return 0;
}

  

C. Memory and De-Evolution

Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.

In a single second, he can modify the length of a single side of the current triangle such that it remains a non-degenerate triangle (triangle of positive area). At any moment of time, the length of each side should be integer.

What is the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y?

Input

The first and only line contains two integers x and y (3 ≤ y < x ≤ 100 000) — the starting and ending equilateral triangle side lengths respectively.

Output

Print a single integer — the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y if he starts with the equilateral triangle of side length x.

Examples

input
6 3
output
4
input
8 5
output
3
input
22 4
output
6

Note

In the first sample test, Memory starts with an equilateral triangle of side length 6 and wants one of side length 3. Denote a triangle with sides ab, and c as (a, b, c). Then, Memory can do .

In the second sample test, Memory can do .

In the third sample test, Memory can do: 

.

题目大意:

将一个长度为x的等边三角形变化成长度为y的等边三角形,一次只能改一条边,并且改完后仍然满足三条边构成三角形。(x>=y)

长变短,和短变长修改次数一样,所以逆向模拟,每次最多能把 最短的一条边 改成 两条长边-1,三条边都大于x,即满足条件。逆向推的好处是能够满足三角形的约束下改变最大。

例:3=>6    (3.3.5),(3.5.7),(5.7.11),(7.11.17)

#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
#define ll long long
int main() {
int x, y,cnt=0;//cnt:修改次数
cin >> x >> y;
int a[3], b;
a[0]=a[1]=a[2]= y;
b= x;
while (a[0] < x || a[1] < x || a[2] < x) {//有一条边小于x,就不满足条件
sort(a, a + 3);
a[0] = a[1] + a[2] - 1;
cnt++;
}
cout << cnt << "\n";
return 0;
}

  

浪在ACM新春大作战的更多相关文章

  1. hiho #1114 : 小Hi小Ho的惊天大作战:扫雷·一

    #1114 : 小Hi小Ho的惊天大作战:扫雷·一 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 故事背景:密室.监视器与充满危机的广场 “我们还是循序渐进,先来考虑这 ...

  2. OneAPM x 腾讯 | OneAPM 技术公开课·深圳 报名:前端性能大作战!

    「 OneAPM 技术公开课」由应用性能管理第一品牌 OneAPM 发起,内容面向 IT 开发和运维人员.云集技术牛人.知名架构师.实践专家共同探讨技术热点. 11月28日,OneAPM 技术公开课第 ...

  3. 刺猬大作战(游戏引擎用Free Pascal写成,GUI用C++写成,使用SDL和Qt4)

    游戏特性[编辑] 游戏引擎用Free Pascal写成,GUI用C++写成,使用SDL和Qt4[2]. 0.9.12开始支持实时动态缩放游戏画面. 个性化[编辑] 刺猬大作战有着高度定制性 游戏模式: ...

  4. cocos2d-x 3.2 它 三消游戏——万圣节大作战

    ***************************************转载请注明出处:http://blog.csdn.net/lttree************************** ...

  5. 【百度地图API】情人节求爱大作战——添加标注功能

    原文:[百度地图API]情人节求爱大作战--添加标注功能 任务描述: 2月2日是除夕,2月14立马来!即将到来的情人节,你想送TA一份什么礼物呢? 不如,在你们居住的地方,画个大大的桃心,表达你对TA ...

  6. [知了堂学习笔记]_用JS制作《飞机大作战》游戏_第2讲(四大界面之间的跳转与玩家飞机的移动)

    一.通过点击按钮事件,实现四大界面之间的跳转: (一)跳转的思路: 1.打开软件,只显示登录界面(隐藏游戏界面.暂停界面.玩家死亡界面) 2.点击微信登录(QQ登录)跳转到游戏界面,隐藏登录界面 3. ...

  7. FC经典游戏还原之:松鼠大作战2

    版权声明:本文原创发布于博客园"优梦创客"的博客空间(id:raymondking123) 原帖地址:http://www.cnblogs.com/raymondking123/p ...

  8. Android破解学习之路(十四)——【Unity3D】王牌大作战破解

    一.前言 今天带来的是王牌大作战的破解教程,游戏下载的话,我是直接去TapTap官网下载的 支付宝内购破解用老套了,今天学点破解的新花样吧!! 二.支付宝内购破解 支付宝的内购破解已经很熟悉了, 直接 ...

  9. 2018.12.21 浪在ACM 集训队第十次测试赛

     浪在ACM 集训队第十次测试赛 A Diverse Substring B Vasya and Books C Birthday D LCM A 传送门 题解 B 传送门 题解: 这道题,就比较简单 ...

随机推荐

  1. max-height实现任意高度元素的展开收缩动画

    http://dobinspark.com.cn/ 前言: 在说到实现元素的展开收缩,通常的想法是通过控制display的元素属性和none之间的切换,虽然说功能可以实现,但是这种展开是没有任何动画的 ...

  2. 解决MyEclipse JAVA EE无法识别Base64问题

    第一步:右击项目选择Build Path,选择Configure Build Path 第二步:点击JRE System Library选择右边的Edit 第三步:选择Alternate JRE,点击 ...

  3. 如何理解低耦合AND高内聚?[转]

    1.高内聚 首先我们来看看内聚的含义:软件含义上的内聚其实是从化学中的分子的内聚演变过来的,化学中的分子间的作用力,作用力强则表现为内聚程度高.在软件中内聚程度的高低,标识着软件设计的好坏. 我们在进 ...

  4. Zabbix——部署(agent和proxy安装)

    前提条件: 已经完成对Zabbix-server的安装 已经完成对Mysql的安装 并且相互和正常使用和访问 配置agent服务器: rpm -Uvh https://repo.zabbix.com/ ...

  5. day 23 模块2

    1.namedtuple     命名元组  -> 类似创建一个类 from collections import namedtuple   # 类 p = namedtuple("P ...

  6. day 20 约束 异常处理 MD5

    1.类的约束(重点): 写一个父类.  父类中的某个方法要抛出一个异常  NotImplementError # 项目经理 class Base:     # 对子类进行了约束. 必须重写该方法    ...

  7. Manjaro Linux KDE个人的一些安装配置

    安装manjaro kde linux的个人步骤 1 换源 1.1 自动寻找最快的源 sudo pacman-mirrors -i -c China -m rank 1.2 修改源文件 sudo ge ...

  8. vue cli3超详细创建多页面配置

    1.首先按照vue cli3 给的入门文档下载个vue cli3 如果之前下载了vue cli2的要先卸载之前的 2.检查安装是否成功 3.ok,现在环境搭建好了,新建项目 vue create he ...

  9. 聊天功能插件Socket.io

    一.Socket.io是什么 是基于时间的实时双向通讯库 基于websocket协议的 前后端通过时间进行双向通讯 配合express快速开发实时应用 二.Socket.io和ajax区别 基于不同的 ...

  10. vue核心概念

    # 1. vuex是什么 github站点: https://github.com/vuejs/vuex 在线文档: https://vuex.vuejs.org/zh-cn/ 简单来说: 对应用中组 ...