結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー hogekihogeki
提出日時 2016-11-13 16:38:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 1,000 ms
コード長 758 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 103,324 KB
実行使用メモリ 22,864 KB
最終ジャッジ日時 2023-08-17 04:20:57
合計ジャッジ時間 6,069 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
18,808 KB
testcase_01 AC 57 ms
22,688 KB
testcase_02 AC 57 ms
18,656 KB
testcase_03 AC 57 ms
20,564 KB
testcase_04 AC 58 ms
22,708 KB
testcase_05 AC 57 ms
18,604 KB
testcase_06 AC 59 ms
18,560 KB
testcase_07 AC 58 ms
22,684 KB
testcase_08 AC 57 ms
20,716 KB
testcase_09 AC 57 ms
20,772 KB
testcase_10 AC 58 ms
20,628 KB
testcase_11 AC 58 ms
22,744 KB
testcase_12 AC 57 ms
18,560 KB
testcase_13 AC 59 ms
22,804 KB
testcase_14 AC 58 ms
22,756 KB
testcase_15 AC 59 ms
20,720 KB
testcase_16 AC 57 ms
20,708 KB
testcase_17 AC 59 ms
20,812 KB
testcase_18 AC 59 ms
20,612 KB
testcase_19 AC 59 ms
20,692 KB
testcase_20 AC 58 ms
20,620 KB
testcase_21 AC 59 ms
22,696 KB
testcase_22 AC 57 ms
22,680 KB
testcase_23 AC 57 ms
20,640 KB
testcase_24 AC 57 ms
20,708 KB
testcase_25 AC 56 ms
20,672 KB
testcase_26 AC 58 ms
22,748 KB
testcase_27 AC 56 ms
20,648 KB
testcase_28 AC 57 ms
22,768 KB
testcase_29 AC 57 ms
22,708 KB
testcase_30 AC 58 ms
20,736 KB
testcase_31 AC 58 ms
20,684 KB
testcase_32 AC 58 ms
22,752 KB
testcase_33 AC 58 ms
20,564 KB
testcase_34 AC 58 ms
20,732 KB
testcase_35 AC 58 ms
20,824 KB
testcase_36 AC 58 ms
22,864 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class SuperFizzBuzz
{
	static public void Main(string[] args)
	{
		long N, a, b, c;
		string[] abc;
		long count = 0;
		N = long.Parse(Console.ReadLine());
		abc = Console.ReadLine().Split(' ');
		a = long.Parse(abc[0]);
		b = long.Parse(abc[1]);
		c = long.Parse(abc[2]);
		long lcm_ab = lcm(a, b);
		long lcm_ac = lcm(a, c);
		long lcm_bc = lcm(b, c);
		long lcm_abc = lcm(lcm_ab, lcm_bc);
		count = N / a + N / b + N / c - N / lcm_ab - N / lcm_ac - N / lcm_bc + N / lcm_abc;
		Console.WriteLine(count);
	}

	static long gcd(long x, long y)
	{
		long t;
		if(x < y)
		{
			t = x;
			x = y;
			y = t;
		}
		if(x % y == 0)
			return y;
		else
			return gcd(y, x % y);
	}

	static long lcm(long x, long y)
	{
		return (x * y) / gcd(x, y);
	}
}
0