题目链接:点击打开链接
塑料瓶牛奶a卢比, 玻璃瓶b卢比, 且玻璃空瓶可以换c元, 问最多可以喝多少牛奶.
玻璃瓶净价是b - c, 如果塑料瓶比净价还便宜, 则均买塑料瓶. 否则尽量买玻璃瓶, 剩下的买塑料瓶.
AC代码:
#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "stack"
#include "cmath"
#include "utility"
#include "map"
#include "set"
#include "vector"
#include "list"
#include "string"
#include "cstdlib"
using namespace std;
typedef long long ll;
#define X first
#define Y second
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
ll n, a, b, c, ans;
int main(int argc, char const *argv[])
{
cin >> n >> a >> b >> c;
if(a < b - c) ans = n / a;
else {
if(n >= b) {
ans = (n - b) / (b - c) + 1;
n -= ans * (b - c);
}
ans += n / a;
}
cout << ans << endl;
return 0;
}