Codeforces 1065A Vasya and Chocolate

一开始幻视成Vanilla and Chocolate诶嘿嘿

题意描述:有S卢布,每个巧克力棒C卢布,每买A个巧克力棒就送B个,问一共可以买多少巧克力。

水的很嘛......小学数学题

先不考虑送的,算出可以买多少个,然后用这个数目除A乘B就是送的数目。



#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
int t,s,a,b,c;
int main(){
    cin>>t;
    while(t--){
    cin>>s>>a>>b>>c;
        LL ans=s/c;
        s=s%c;
        ans+=(ans/a)*b;
        printf("%lld\n",ans);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/soul-M/p/9776045.html