結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kkslucy1kkslucy1
提出日時 2018-03-13 00:16:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 158,736 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 16:32:52
合計ジャッジ時間 2,601 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
6,944 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll gcd(ll n, ll m) {
	if (n < m) {
		ll c = n;
		n = m;
		m = c;
	}
	if (n%m == 0) {
		return m;
	}
	else {
		return gcd(m, n%m);
	}
}
int main() {
	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	ll ans = 0;
	ans += n / a + n / b + n / c;
	ll ab = a * b / gcd(a, b);
	ll bc = b * c / gcd(b, c);
	ll ca = c * a / gcd(c, a);
	ans -= n / ab + n / bc + n / ca;
	ll gcd_abc = gcd(a, gcd(b, c));
	ll abc = a * b*c / gcd_abc / gcd_abc;
	ans += n / abc;
	cout << ans << endl;

	return 0;
}
0