欢迎光临散文网 会员登陆 & 注册

CF 1849A - Morning Sandwich

2023-08-16 11:46 作者:您是打尖儿还是住店呢  | 我要投稿

Monocarp always starts his morning with a good ol' sandwich. Sandwiches Monocarp makes always consist of bread, cheese and/or ham.


A sandwich always follows the formula:

a piece of bread a slice of cheese or ham a piece of bread…

a slice of cheese or ham a piece of bread

So it always has bread on top and at the bottom, and it alternates between bread and filling, where filling is a slice of either cheese or ham. Each piece of bread and each slice of cheese or ham is called a layer.


Today Monocarp woke up and discovered that he has b pieces of bread, c slices of cheese and h slices of ham. What is the maximum number of layers his morning sandwich can have?

Input

The first line contains a single integer t (1≤t≤1000) — the number of testcases.

Each testcase consists of three integers b,c and h (2≤b≤100; 1≤c,h≤100) — the number of pieces of bread, slices of cheese and slices of ham, respectively.

Output

For each testcase, print a single integer — the maximum number of layers Monocarp's morning sandwich can have.

--------------------------------------

Monocarp 总是以美味的三明治开始新的一天。 Monocarp 制作的三明治通常由面包、奶酪和/或火腿组成。


三明治总是遵循以下公式:

一片面包一片奶酪或火腿一片面包……

一片奶酪或火腿 一块面包

所以它的顶部和底部总是有面包,并且它在面包和馅料之间交替,其中馅料是一片奶酪或火腿。 每片面包和每片奶酪或火腿称为一层。


今天Monocarp醒来发现他有b片面包,c片奶酪和h片火腿。 他的早餐三明治最多可以有多少层?

输入

第一行包含一个整数 t (1≤t≤1000) — 测试用例的数量。

每个测试用例由三个整数 b、c 和 h 组成(2≤b≤100;1≤c,h≤100)——分别是面包片、奶酪片和火腿片的数量。

输出

对于每个测试用例,打印一个整数 - Monocarp 的早晨三明治可以有的最大层数。

--------------------------------

确定三明治的最大层次,其实就是判断面包跟火腿还有起司的数量即可,下面是代码:


CF 1849A - Morning Sandwich的评论 (共 条)

分享到微博请遵守国家法律