题意翻译
题意
VasyaVasya最喜欢的超市里有一个优惠:如果顾客买aa块巧克力,他就可以免费购买bb块巧克力。这个优惠可以多次使用。VasyaVasya现在有ss卢布,他想免费得到尽可能多的巧克力。每块巧克力的价格是cc卢布。请帮助VasyaVasya计算出他最大能得到的巧克力数!
输入
第一行包含一个整数t(1\le t\le 100)t(1≤t≤100)-数据组数。 接下来的t行每一行包含4个整数ss,aa,bb,c(1\le s,a,b,c\le 10^9)c(1≤s,a,b,c≤109)。VasyaVasya有ss卢布,优惠时必须购买的巧克力的数量aa,免费获得的巧克力的数量bb,以及一条的成本cc。
输出
输出tt行表示每一次可得的最大巧克力数
说明
样例一,VasyaVasya可以买到99块,33块免费,另外买一块,所以他可以买1313块。
样例二,VasyaVasya买了10000000001000000000块,免费得到了10000000000000000001000000000000000000块。所以他有10000000010000000001000000001000000000块。
题目描述
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!
输入输出格式
输入格式:
The first line contains one integer tt ( 1 \le t \le 1001≤t≤100 ) — the number of testcases.
Each of the next tt lines contains four integers s, a, b, c~(1 \le s, a, b, c \le 10^9)s,a,b,c (1≤s,a,b,c≤109) — 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.
输出格式:
Print tt lines. ii -th line should contain the maximum possible number of chocolate bars Vasya can get in ii -th test.
输入输出样例
输入样例#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 1313bars.
In the second test Vasya buys 10000000001000000000 bars and gets 10000000000000000001000000000000000000 for free. So he has 10000000010000000001000000001000000000 bars.
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int s,a,b,c,l,l1,l2,ans;
cin>>s>>a>>b>>c;
l=s/c;
if(l<a)
{
ans=l;
}
else
{
l1=l/a;
l2=l1*b;
ans=l2+l;
}
cout<<ans<<endl;
}
return 0;
}