結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー hashiryo
提出日時 2018-04-22 18:45:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 803 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 59,764 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 05:57:20
合計ジャッジ時間 1,672 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//


#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N;
ll a,b,c;
ll ans;

ll gcd(ll x,ll y){
    return y==0? x:gcd(y,x%y);
}

ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}

int main() {
    // insert code here...    return 0;
  //////
    // input from txt
    /*
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::ofstream out("output.txt");
    std::cout.rdbuf(out.rdbuf());
   ///////
     */
    cin >> N;
    cin >> a >> b >> c;
    
    ll ablcm = lcm(a,b);
    ans = N/a+N/b+N/c-N/ablcm-N/lcm(b,c)-N/lcm(c,a)+N/lcm(ablcm,c);
    cout << ans << endl;
    
    return 0;
}
0