結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kenken
提出日時 2018-07-16 12:15:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,197 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 107,436 KB
実行使用メモリ 23,920 KB
最終ジャッジ日時 2023-08-10 17:02:28
合計ジャッジ時間 6,102 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,696 KB
testcase_01 AC 58 ms
21,724 KB
testcase_02 AC 61 ms
23,748 KB
testcase_03 AC 62 ms
23,696 KB
testcase_04 AC 64 ms
21,676 KB
testcase_05 AC 59 ms
21,712 KB
testcase_06 AC 61 ms
21,652 KB
testcase_07 WA -
testcase_08 AC 60 ms
21,768 KB
testcase_09 AC 59 ms
23,728 KB
testcase_10 AC 59 ms
21,712 KB
testcase_11 WA -
testcase_12 AC 60 ms
21,860 KB
testcase_13 AC 61 ms
23,720 KB
testcase_14 AC 61 ms
21,692 KB
testcase_15 AC 60 ms
23,660 KB
testcase_16 AC 60 ms
23,704 KB
testcase_17 AC 57 ms
23,708 KB
testcase_18 AC 59 ms
21,692 KB
testcase_19 AC 59 ms
23,720 KB
testcase_20 AC 59 ms
21,680 KB
testcase_21 AC 58 ms
21,676 KB
testcase_22 AC 58 ms
21,688 KB
testcase_23 AC 58 ms
21,740 KB
testcase_24 AC 59 ms
21,692 KB
testcase_25 AC 58 ms
21,720 KB
testcase_26 AC 57 ms
21,688 KB
testcase_27 AC 59 ms
23,716 KB
testcase_28 AC 58 ms
21,740 KB
testcase_29 AC 61 ms
21,588 KB
testcase_30 AC 62 ms
23,748 KB
testcase_31 AC 62 ms
23,768 KB
testcase_32 AC 58 ms
21,680 KB
testcase_33 WA -
testcase_34 AC 57 ms
21,752 KB
testcase_35 AC 57 ms
23,716 KB
testcase_36 AC 57 ms
23,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

public class CountDivisors{
    static long GCD(long a, long b) {return (b == 0) ? a : GCD(b, a % b);}
    static long LCM(long a, long b) {return a / GCD(a, b) * b;}
    
    public static void Main(){
        var n = long.Parse(Console.ReadLine());
        var input = Console.ReadLine();
        var inputArr = input.Split(' ');
        var a = inputArr.Select(s => long.Parse(s)).ToArray();
        Array.Sort(a);
        for(var i = 0; i < 2; i++){
            if(a[2]%a[i] == 0){
                a[2] = a[i];
            }
        }
        for(var j = 2; j > 0; j--){
            if(a[j]%a[0] == 0){
                a[j] = a[0];
            }
        }
        var divArray = a.Distinct().ToArray();
        long numOfDivs = 0;
        
        foreach(var x in divArray){
            numOfDivs += n/x;
        }
        var len = divArray.Length;
        if(len == 3){
            numOfDivs += n / LCM(a[0], LCM(a[1], a[2]));
        }
        for(var i = 0; i < len; i++){
            for(var j = len-1; j > i; j--){
                numOfDivs -= n / LCM(a[i], a[j]);
            }
        }
        
        Console.WriteLine(numOfDivs);
        
    }
}
0