Codeforces Global Round 3 1148A. Another One Bites The Dust

A. Another One Bites The Dust

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Let's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.

You have a strings “a”, b strings “b” and c strings “ab”. You want to choose some subset of these strings and concatenate them in any arbitrarily order.

What is the length of the longest good string you can obtain this way?

Input

The first line contains three positive integers a, b, c (1≤a,b,c≤109) — the number of strings “a”, “b” and “ab” respectively.

Output

Print a single number — the maximum possible length of the good string you can obtain.

Examples

input

1 1 1

output

4

input

2 1 2

output

7

input

3 5 2

output

11

input

2 2 1

output

6

input

1000000000 1000000000 1000000000

output

4000000000

Note

In the first example the optimal string is “baba”.

In the second example the optimal string is “abababa”.

In the third example the optimal string is “bababababab”.

In the fourth example the optimal string is “ababab”.

水题:

题意:

输入三个数分别是a的数量,b的数量,ab的数量,然后变成abababababababababab这种最长是多少。

思路:

最后一个可以不用管,因为他铁定是可以排进去的因为它是ab形式,它们自己不管怎么排都是good字符串,然后看a的数量和b的数量,可以凑成几个ab,然后看ababab这种形式可以第一个a前面放个b,最后一个b后面可以放个a,那么a的数量和b的数量不相等,就可以总数加1。

操作

那么最后一个可以直接乘2加进sum,然后sum加上a的数量和b的数量的最小值乘2,然后看a的数量和b的数量是否相等,不相等sum1

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	ll a,b,c;
	while(cin>>a>>b>>c){
		ll sum=c*2;//最后一个可以直接乘2加进sum
		sum+=min(a,b)*2;//sum加上a的数量和b的数量的最小值乘2
		if(a!=b)sum++;//看a的数量和b的数量是否相等,不相等sum加1
		cout<<sum<<endl; 
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GUESSERR

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值