結果

問題 No.316 もっと刺激的なFizzBuzzをください
コンテスト
ユーザー vjudge1
提出日時 2025-12-24 02:35:53
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 351µs
コード長 835 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,098 ms
コンパイル使用メモリ 208,608 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-19 19:02:01
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define I first
#define II second
#define ii pair<int, int>
#define ll long long
using namespace std;
const long long P = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;

void input()
{
#define TASKNAME ""
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen(TASKNAME ".inp", "r"))
    {
        freopen(TASKNAME ".inp", "r", stdin);
        freopen(TASKNAME ".out", "w", stdout);
    }
}
ll a, b, c, t,n;
ll lcm(ll x, ll y)
{
    return x/__gcd(x, y)*y;
}
ll dem(ll x, ll a, ll b, ll c)
{
    if (x <= 0)
        return 0;
    ll res = x/a+x/b+x/c+x/(lcm(lcm(a, b), c))-x/(lcm(a, b))-x/(lcm(b, c))-x/(lcm(a, c));
    return res;
}
int main()
{
    input();
    cin >> n >> a >> b >> c;
    ll l = 1,r=n;
     cout << dem(r, a, b, c)-dem(l-1, a, b, c);
    return 0;
}
0