結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー mdj982mdj982
提出日時 2015-12-30 18:58:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,112 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 95,520 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 12:41:51
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)

using namespace std;
typedef long long int lint;

int solve_GCD(int x, int y) {
	while (x != y) {
		if (x > y) {
			x -= y;
		}
		else {
			y -= x;
		}
	}
	return x;
}

int solve_LCM(int x, int y) {
	int z = solve_GCD(x, y);
	return x*y / z;
}


//***** Main Program *****
int main() {
	int N;
	vector<int> a(3);
	cin >> N >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end(), greater<int>());
	int lcm01 = solve_LCM(a[0], a[1]);
	int lcm12 = solve_LCM(a[1], a[2]);
	int lcm20 = solve_LCM(a[2], a[0]);
	int lcm = solve_LCM(a[0], lcm12);
	int x0 = N / a[0];
	int x1 = N / a[1];
	int x2 = N / a[2];
	int xx01 = N / lcm01;
	int xx12 = N / lcm12;
	int xx20 = N / lcm20;
	int xxx = N / lcm;
	int ret = x0 + x1 + x2 - xx01 - xx12 - xx20 + xxx;
	cout << ret << endl;
}
0