CF1303B.National Project

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Your company was appointed to lay new asphalt on the highway of length nn . You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.

Skipping the repair is necessary because of the climate. The climate in your region is periodical: there are gg days when the weather is good and if you lay new asphalt these days it becomes high-quality pavement; after that, the weather during the next bb days is bad, and if you lay new asphalt these days it becomes low-quality pavement; again gg good days, bb bad days and so on.

You can be sure that you start repairing at the start of a good season, in other words, days 1,2,,g1, 2, \dots, g are good.

You don't really care about the quality of the highway, you just want to make sure that at least half of the highway will have high-quality pavement. For example, if the n=5n = 5 then at least 33 units of the highway should have high quality; if n=4n = 4 then at least 22 units should have high quality.

What is the minimum number of days is needed to finish the repair of the whole highway?

输入格式

The first line contains a single integer TT ( 1T1041 \le T \le 10^4 ) — the number of test cases.

Next TT lines contain test cases — one per line. Each line contains three integers nn , gg and bb ( 1n,g,b1091 \le n, g, b \le 10^9 ) — the length of the highway and the number of good and bad days respectively.

输出格式

Print TT integers — one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.

输入输出样例

  • 输入#1

    3
    5 1 1
    8 10 10
    1000000 1 1000000

    输出#1

    5
    8
    499999500000

说明/提示

In the first test case, you can just lay new asphalt each day, since days 1,3,51, 3, 5 are good.

In the second test case, you can also lay new asphalt each day, since days 11 - 88 are good.

首页