結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー ken
提出日時 2018-07-15 10:55:00
言語 C#(csc)
(csc 3.9.0)
結果
MLE  
実行時間 -
コード長 911 bytes
コンパイル時間 3,622 ms
コンパイル使用メモリ 106,240 KB
実行使用メモリ 830,420 KB
最終ジャッジ日時 2024-10-15 12:56:29
合計ジャッジ時間 4,473 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 4 MLE * 1 -- * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

public class CountDivisors{
    static void AddDiv(HashSet<long> h, long x, long n){
        for(long i = x; i <= n; i+=x){
            h.Add(i);
        }
    }
    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);
        var divSet = new HashSet<long>(new long[]{});
        
        
        if(a[0] == 1){
            Console.WriteLine(n);
        }else{
            AddDiv(divSet, a[0], n);
            if(a[1]%a[0] != 0){
                AddDiv(divSet, a[1], n);
            }
            if(a[2]%a[1] != 0 && a[2]%a[0] != 0){
                AddDiv(divSet, a[2], n);
            }
            Console.WriteLine(divSet.Count);
        }
    }
}
0