Educational Codeforces Round 52 (Rated for Div. 2) A. Vasya and Chocolate

A. Vasya and Chocolate

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

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

Input
The first line contains one integer t (1≤t≤100) — the number of testcases.

Each of the next t lines contains four integers 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.

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

Example
inputCopy

2
10 3 1 1
1000000000 1 1000000000 1
outputCopy
13
1000000001000000000
Note
In the first test of the example Vasya can buy 9 bars, get 3 for free, buy another bar, and so he will get 13 bars.

In the second test Vasya buys 1000000000 bars and gets 1000000000000000000 for free. So he has 1000000001000000000 bars.
水题

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t ;
	long long s,a,b,p,ans=0;
	scanf("%d",&t);
	while(t--)
	{
	
	cin>>s>>a>>b>>p;
	ans=s/p+(s/p)/a*b;
	cout<<ans<<endl;
	
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值