CF1065A.Vasya and Chocolate

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There is a special offer in Vasya's favourite supermarket: if the customer buys aa chocolate bars, he or she may take bb additional bars for free. This special offer can be used any number of times.

Vasya currently has ss roubles, and he wants to get as many chocolate bars for free. Each chocolate bar costs cc roubles. Help Vasya to calculate the maximum possible number of chocolate bars he can get!

瓦西娅最喜爱的超市有一个特别优惠:如果顾客购买 aa 块巧克力,就可以免费再拿 bb 块。该优惠可以使用任意多次。

瓦西娅目前有 ss 卢布,他希望尽可能多地免费获得巧克力。每块巧克力售价为 cc 卢布。请帮助瓦西娅计算他最多能获得多少块巧克力!

输入格式

The first line contains one integer tt (1≤t≤1001 \le t \le 100) — the number of testcases.

Each of the next tt lines contains four integers s,a,b,c (1≤s,a,b,c≤109)s, a, b, c~(1 \le s, a, b, c \le 10^9) — the number of roubles Vasya has, the number of chocolate bars you have to buy to use the special offer, the number of bars you get for free, and the cost of one bar, respectively.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 测试用例的数量。

接下来的 tt 行中,每行包含四个整数 s,a,b,cs, a, b, c(1≤s,a,b,c≤1091 \le s, a, b, c \le 10^9)—— 分别表示瓦夏拥有的卢布数、使用特价优惠所需购买的巧克力条数、免费获得的巧克力条数,以及每条巧克力的价格。

输出格式

Print tt lines. ii-th line should contain the maximum possible number of chocolate bars Vasya can get in ii-th test.

输出 tt 行。第 ii 行应包含 Vasya 在第 ii 个测试中能获得的巧克力棒的最大可能数量。

输入输出样例

  • 输入#1

    2
    10 3 1 1
    1000000000 1 1000000000 1

    输出#1

    13
    1000000001000000000

说明/提示

In the first test of the example Vasya can buy 99 bars, get 33 for free, buy another bar, and so he will get 1313 bars.

In the second test Vasya buys 10000000001000000000 bars and gets 10000000000000000001000000000000000000 for free. So he has 10000000010000000001000000001000000000 bars.

在示例的第一个测试中,瓦西娅可以购买 99 块巧克力,免费获得 33 块,再额外购买 11 块,因此他总共获得 1313 块巧克力。

在第二个测试中,瓦西娅购买了 10000000001000000000 块巧克力,并免费获得 10000000000000000001000000000000000000 块。因此他总共拥有 10000000010000000001000000001000000000 块巧克力。

输入解题思路,AI测评打分。不知道怎么写?

首页