CF1148A.Another One Bites The Dust
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
我们称一个字符串是“好”的,当且仅当它仅由两种字母——‘a’ 和 ‘b’ 组成,且任意两个相邻字母均不相同。例如,“baba” 和 “aba” 是好字符串,而 “abb” 是坏字符串。
你有 a 个字符串 “a”、b 个字符串 “b” 以及 c 个字符串 “ab”。你需要从中选出某个子集,并以任意顺序将它们连接起来。
通过这种方式,你能得到的最长的好字符串的长度是多少?
输入格式
The first line contains three positive integers a, b, c (1≤a,b,c≤109) — the number of strings "a", "b" and "ab" respectively.
第一行包含三个正整数 a、b、c(1≤a,b,c≤109),分别表示字符串 "a"、"b" 和 "ab" 的数量。
输出格式
Print a single number — the maximum possible length of the good string you can obtain.
输出一个整数——你能得到的“好字符串”的最大可能长度。
输入输出样例
输入#1
1 1 1
输出#1
4
输入#2
2 1 2
输出#2
7
输入#3
3 5 2
输出#3
11
输入#4
2 2 1
输出#4
6
输入#5
1000000000 1000000000 1000000000
输出#5
4000000000
说明/提示
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".
在第一个例子中,最优字符串是 "baba"。
在第二个例子中,最优字符串是 "abababa"。
在第三个例子中,最优字符串是 "bababababab"。
在第四个例子中,最优字符串是 "ababab"。
输入解题思路,AI测评打分。不知道怎么写?