题目链接:

# 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. 用模板引擎Art-Template渲染空格或换行符引发的一场“命案”

    一.绪论 说实话,真的不知道如何给这篇博客命名,因为我觉得应该有一些小伙伴遇到跟我同样的问题正在抓耳挠腮中. 二.导火索 最近在做一个移动H5翻页的功能,类似于MAKA模板那种.假设大致框架如下 ​ ...

  2. Swift_方法

    Swift_方法 点击查看源码 ///方法 class Methods: NSObject { func test() { // self.testInstanceMethods() //实例方法 s ...

  3. RabbitMQ初学之踩坑记录

    1:账号或密码错误 com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused usi ...

  4. 500. Keyboard Row (5月26日)

    解答 class Solution { public: vector<string> findWords(vector<string>& words) { vector ...

  5. 离不开的微服务架构,脱不开的RPC细节(值得收藏)!!!

    服务化有什么好处? 服务化的一个好处就是,不限定服务的提供方使用什么技术选型,能够实现大公司跨团队的技术解耦,如下图所示: 服务A:欧洲团队维护,技术背景是Java 服务B:美洲团队维护,用C++实现 ...

  6. CentOS 7.x下升级Python版本到3.x系列(新老版本共存)

    由于python官方已宣布2.x系列即将停止支持,为了向前看,我们升级系统的python版本为3.x系列服务器系统为当前最新的CentOS 7.4 1.安装前查看当前系统下的python版本号 # p ...

  7. 【JavaWeb】从零实现用户登录

    1.数据库预备 1.1 SQL 创建数据库 create database db; 创建表 create table userInfo( id int primary key , name ), pa ...

  8. 小白CSS学习日记-----杂乱无序记录(3)

    1.后代选择器 .antzone li { } class='antzone' 所有子孙后代中的li   2.子选择器 .antzone > li { } class='antzone' 的子一 ...

  9. 中国软件大会上大快搜索入选中国数字化转型TOP100服务商

    大快搜索自荣获“2018中国大数据企业50强”殊荣,12月20日在由工信部指导,中国电子信息产业化发展研究院主办的2018中国软件大会上,大快搜索获评“2018中国大数据基础软件领域领军企业”称号,入 ...

  10. 从Oracle导出数据并导入到Hive

    1.配置源和目标的数据连接 源(oracle): 目标(Hive 2.1.1),需要事先将hive的驱动程序导入HHDI的lib目录中. Hive2.1.1需要的jar包如下:可根据自身情况更换had ...