// STOOOOOOOOOOOOOOOOOOOOOOOOO hzt CCCCCCCCCCCCCCCCCCCCCCCORZ
#include <algorithm>
#include <cassert>
#include <climits>
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using LL = unsigned long long;
using PII = pair<int, int>;
constexpr int kN = 1e5 + 1;
LL h, a[3];
LL d[kN];
bool t[kN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> h >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
fill_n(d, a[0], ULLONG_MAX);
queue<int> q;
d[1] = t[1] = 1, q.push(1);
for (; !q.empty(); q.pop()) {
int x = q.front();
t[x] = 0;
for (int i : {1, 2}) {
int v = (x + a[i]) % a[0];
if (d[v] > d[x] + a[i]) {
d[v] = d[x] + a[i];
if (!t[v])
t[v] = 1, q.push(v);
}
}
}
LL ans = 0;
for (int i = 0; i < a[0]; i++) {
if (h >= d[i])
ans += (h - d[i]) / a[0] + 1;
}
cout << ans << '\n';
return 0;
}
看上去并没有什么问题,但是奇怪地 WA on #1 了。
改成 h-- 后从 0 开始就过了。为啥啊