CF1303B.National Project
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Your company was appointed to lay new asphalt on the highway of length n. 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 g 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 b days is bad, and if you lay new asphalt these days it becomes low-quality pavement; again g good days, b 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,…,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=5 then at least 3 units of the highway should have high quality; if n=4 then at least 2 units should have high quality.
What is the minimum number of days is needed to finish the repair of the whole highway?
你们公司被委派为一条长度为 n 的高速公路铺设新的沥青。已知每天你只能选择以下两种操作之一:修复高速公路的一个单位(即在高速公路的一个单位上铺设新沥青),或者跳过当天的修复工作。
跳过修复是必要的,这是由于当地气候的影响。该地区的气候呈周期性变化:每 g 天为一个“好天气期”,在此期间铺设的沥青会形成高质量路面;随后是连续 b 天的“坏天气期”,在此期间铺设的沥青则形成低质量路面;之后再次进入 g 天好天气期、b 天坏天气期,如此循环往复。
你可以确定,修复工作始于一个好天气期的起始日,即第 1,2,…,g 天均为好天气。
你并不真正关心整条公路的质量,只希望确保至少一半的公路路段具有高质量路面。例如,若 n=5,则至少需要 3 个单位为高质量;若 n=4,则至少需要 2 个单位为高质量。
问:完成整条高速公路修复所需的最少天数是多少?
输入格式
The first line contains a single integer T (1≤T≤104) — the number of test cases.
Next T lines contain test cases — one per line. Each line contains three integers n, g and b (1≤n,g,b≤109) — the length of the highway and the number of good and bad days respectively.
第一行包含一个整数 T(1≤T≤104)—— 测试用例的数量。
接下来 T 行,每行一个测试用例。每行包含三个整数 n、g 和 b(1≤n,g,b≤109)—— 分别表示高速公路的长度、好天气的天数和坏天气的天数。
输出格式
Print T 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.
输出 T 个整数——每个测试用例对应一个整数。对于每个测试用例,输出修复整条公路所需的最少天数,要求其中至少一半的路段为高质量。
输入输出样例
输入#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,5 are good.
In the second test case, you can also lay new asphalt each day, since days 1-8 are good.
在第一个测试用例中,你可以每天铺设新的沥青,因为第 1、3、5 天都是好天气。
在第二个测试用例中,你也可以每天铺设新的沥青,因为第 1–8 天都是好天气。
输入解题思路,AI测评打分。不知道怎么写?