CF1065A Vasya and Chocolate

滴答滴答---题目链接 

题意翻译

题意

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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值