結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー NoNo
提出日時 2018-01-28 04:18:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 1,277 bytes
コンパイル時間 2,066 ms
コンパイル使用メモリ 104,988 KB
実行使用メモリ 23,012 KB
最終ジャッジ日時 2023-08-28 10:36:47
合計ジャッジ時間 6,588 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
20,852 KB
testcase_01 AC 68 ms
20,788 KB
testcase_02 AC 67 ms
18,836 KB
testcase_03 AC 68 ms
20,936 KB
testcase_04 AC 67 ms
20,964 KB
testcase_05 AC 67 ms
20,932 KB
testcase_06 AC 66 ms
20,800 KB
testcase_07 AC 67 ms
20,908 KB
testcase_08 AC 66 ms
20,952 KB
testcase_09 AC 66 ms
18,856 KB
testcase_10 AC 68 ms
20,864 KB
testcase_11 AC 68 ms
20,928 KB
testcase_12 AC 67 ms
21,024 KB
testcase_13 AC 68 ms
20,844 KB
testcase_14 AC 68 ms
20,960 KB
testcase_15 AC 67 ms
22,840 KB
testcase_16 AC 65 ms
18,796 KB
testcase_17 AC 68 ms
22,972 KB
testcase_18 AC 68 ms
20,844 KB
testcase_19 AC 67 ms
20,840 KB
testcase_20 AC 69 ms
22,936 KB
testcase_21 AC 67 ms
20,908 KB
testcase_22 AC 67 ms
22,844 KB
testcase_23 AC 67 ms
20,836 KB
testcase_24 AC 68 ms
22,844 KB
testcase_25 AC 66 ms
23,012 KB
testcase_26 AC 66 ms
20,792 KB
testcase_27 AC 67 ms
22,896 KB
testcase_28 AC 68 ms
20,900 KB
testcase_29 AC 67 ms
20,828 KB
testcase_30 AC 67 ms
20,820 KB
testcase_31 AC 68 ms
20,804 KB
testcase_32 AC 68 ms
20,920 KB
testcase_33 AC 69 ms
22,864 KB
testcase_34 AC 70 ms
20,836 KB
testcase_35 AC 68 ms
22,912 KB
testcase_36 AC 68 ms
22,896 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = decimal.Parse(Console.ReadLine());
            var ss = Console.ReadLine().Split();
            var an = decimal.Parse(ss[0]);
            var bn = decimal.Parse(ss[1]);
            var cn = decimal.Parse(ss[2]);
            decimal a = Math.Floor(n / an);
            decimal b = Math.Floor(n / bn);
            decimal c = Math.Floor(n / cn);

            decimal ab = Math.Floor(n / (an * bn / Gcd(an, bn)));
            decimal bc = Math.Floor(n / (bn * cn /Gcd(bn, cn)));
            decimal ac = Math.Floor(n / (an * cn / Gcd(an, cn)));
            decimal g = bn * cn / Gcd(bn, cn);
            decimal abc = Math.Floor( n / (an * g / Gcd(an,g)));

            decimal ab_c = ab - abc;
            decimal bc_a = bc - abc;
            decimal ac_b = ac - abc;

            decimal ans = (a + b + c) - ab - bc - ac + abc;

            Console.WriteLine(ans);
        }

        public static decimal Gcd(decimal a, decimal b)
        {
            if (a < b) return Gcd(b, a);
            while (b != 0)
            {
                var c = a % b;
                a = b;
                b = c;
            }
            return a;
        }
    }
}
0