結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー femto
提出日時 2016-08-19 01:53:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 560 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-21 12:22:09
合計ジャッジ時間 1,802 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, a, b, c;
	cin >> N >> a >> b >> c;

	ll ans = 0;
	ans += N / a + N / b + N / c;
	ans -= N / (a * b / gcd(a, b)) + N / (b * c / gcd(b, c)) + N / (c * a / gcd(c, a));
	ll d = a * b / gcd(a, b);
	ans += N / (c * d / gcd(c, d));

	cout << ans << endl;
}
0