結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー vjudge1
提出日時 2025-02-05 01:18:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 1,438 bytes
コンパイル時間 5,723 ms
コンパイル使用メモリ 272,076 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-02-05 01:18:24
合計ジャッジ時間 8,363 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

//Bismillah
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define forn(i, a, n) for (int i = a; i < n; i++)
#define fornr(i, a, n) for (int i = n - 1; i >= a; i--)
#define print(a) cout << a << "\n";
#define printarr(a) forn(i, 0, a.size()) cout << a[i] << " "; cout << endl;
#define file_read(filepath) freopen(filepath, "r", stdin);
#define file_write(filepath) freopen(filepath, "w", stdout);
#define f first
#define s second
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sorted(a) is_sorted(all(a))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define vpii vector<pair<int,int>>
#define MOD1 1000000007
#define mii map<int,int>
#define sz(a) a.size()

void solve(){
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    cnt += n / a;
    cnt += n / b;
    cnt += n / c;
    cnt -= n / ((a * b) / __gcd(a,b));
    int cc = a * b;
    cnt -= n / ((c * a) / __gcd(a,c));
    cnt -= n / ((c * b) / __gcd(b,c));
    int ab = (a * b) / __gcd(a,b);
    int abc = (ab * c) / __gcd(ab,c);
    cnt += n / abc;
    print(cnt) 
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
    	solve();
	}
}
0