• A. Morning Sandwich


    time limit per test

    2 seconds

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    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≤10001≤�≤1000) — the number of testcases.

    Each testcase consists of three integers b,c�,� and hℎ (2≤b≤1002≤�≤100; 1≤c,h≤1001≤�,ℎ≤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.

    Example

    input

    Copy

     
    

    3

    2 1 1

    10 1 2

    3 7 8

    output

    Copy

    3
    7
    5
    

    Note

    In the first testcase, Monocarp can arrange a sandwich with three layers: either a piece of bread, a slice of cheese and another piece of bread, or a piece of bread, a slice of ham and another piece of bread.

    In the second testcase, Monocarp has a lot of bread, but not too much filling. He can arrange a sandwich with four pieces of bread, one slice of cheese and two slices of ham.

    In the third testcase, it's the opposite — Monocarp has a lot of filling, but not too much bread. He can arrange a sandwich with three pieces of bread and two slices of cheese, for example.

    解题说明:此题是一道模拟题,按照题目意思做三明治,比较面包的个数和两种夹心的个数即可。

    1. #include
    2. int t;
    3. int b, c, h;
    4. int main()
    5. {
    6. scanf("%d", &t);
    7. for (int i = 0; i < t; i++)
    8. {
    9. scanf("%d%d%d", &b, &c, &h);
    10. if (b <= c + h)
    11. {
    12. printf("%d\n", b + (b - 1));
    13. }
    14. else
    15. {
    16. printf("%d\n", (c + h) + (c + h + 1));
    17. }
    18. }
    19. return 0;
    20. }

  • 相关阅读:
    【英雄哥七月集训】第 27天:图
    卡西欧5800程序集 第17篇 断链处理——长链篇
    终于解决VScode中python/C++打印中文全是乱码的问题了
    从数据图表引入到最终效果呈现:全面解析JVS智能BI图表配置流程
    买卖股票的最佳时机
    Spring 事务和事务传播机制
    K近邻算法
    开箱评测:双十一刚买的云服务器,到底好不好用?
    经典题记录 字符串相加/相乘
    笔记43:ResNet 结构详解
  • 原文地址:https://blog.csdn.net/jj12345jj198999/article/details/134341291