結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー bayashiko_rbayashiko_r
提出日時 2019-08-01 14:46:27
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,464 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 98,404 KB
実行使用メモリ 24,872 KB
最終ジャッジ日時 2023-09-18 17:22:34
合計ジャッジ時間 5,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int a = int.Parse(s.Split(' ')[0]);
        int b = int.Parse(s.Split(' ')[1]);
        int c = int.Parse(s.Split(' ')[2]);

        //回答となる数値
        int ans = 0;

        int a_num = 0;  //aの倍数の個数
        int b_num = 0;  //bの倍数の個数
        int c_num = 0;  //cの倍数の個数

        int a_b_num = 0;
        int b_c_num = 0;
        int c_a_num = 0;

        int a_b_c_num = 0;

        //検証
        a_num = N / a;
        b_num = N / b;
        c_num = N / c;

        a_b_num = N / LCM(a, b);
        b_c_num = N / LCM(b, c);
        c_a_num = N / LCM(c, a);

        a_b_c_num = N / LCM(LCM(a, b), c);

        ans = a_num + b_num + c_num - (a_b_num + b_c_num + c_a_num) + a_b_c_num;

        //出力
        Console.WriteLine(ans);
    }

    //ユークリッドの互除法
    public static int GCD(int a, int b) {
        if (a < b) {
            return GCD(b, a);
        }

        while (b != 0) {
            int amari = a % b;
            a = b;
            b = amari;
        }
        return a;
    }

    //最小公倍数を求める
    public static int LCM(int a, int b) {
        return a * b / GCD(a, b);
    }
}
0