#line 1 "test/01_Math/01_NumberTheory/03.01_yukicoder-0316.test.cpp" #define PROBLEM "https://yukicoder.me/problems/no/316" #line 1 "template/template.hpp" #include using namespace std; #line 3 "01_Math/01_NumberTheory/02.01_gcd.hpp" /** * @brief 最大公約数 * @docs docs/gcd.md */ uint64_t gcd(uint64_t a, uint64_t b) { while (b) { uint64_t c = a % b; a = b; b = c; } return a; } #line 3 "01_Math/01_NumberTheory/03.01_lcm.hpp" /** * @brief 最小公倍数 * @docs docs/lcm.md */ uint64_t lcm(uint64_t a, uint64_t b) { return a / gcd(a, b) * b; } #line 4 "test/01_Math/01_NumberTheory/03.01_yukicoder-0316.test.cpp" long long num(int n, int x) { return n / x; } int main() { long long N, a, b, c; cin >> N >> a >> b >> c; long long ans = num(N, a) + num(N, b) + num(N, c); ans -= num(N, lcm(a, b)) + num(N, lcm(b, c)) + num(N, lcm(c, a)); ans += num(N, lcm(a, lcm(b, c))); cout << ans << endl; }