結果

問題 No.312 置換処理
ユーザー 14番14番
提出日時 2016-05-17 01:20:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,889 bytes
コンパイル時間 1,062 ms
コンパイル使用メモリ 114,184 KB
実行使用メモリ 27,340 KB
最終ジャッジ日時 2024-04-27 10:43:08
合計ジャッジ時間 4,214 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
25,264 KB
testcase_01 AC 38 ms
26,824 KB
testcase_02 AC 41 ms
26,952 KB
testcase_03 AC 41 ms
27,328 KB
testcase_04 AC 30 ms
25,136 KB
testcase_05 AC 29 ms
24,764 KB
testcase_06 AC 30 ms
25,140 KB
testcase_07 AC 33 ms
27,072 KB
testcase_08 AC 30 ms
24,912 KB
testcase_09 AC 29 ms
25,016 KB
testcase_10 AC 30 ms
27,340 KB
testcase_11 AC 32 ms
27,064 KB
testcase_12 AC 30 ms
24,764 KB
testcase_13 AC 29 ms
25,164 KB
testcase_14 AC 30 ms
24,916 KB
testcase_15 AC 31 ms
24,916 KB
testcase_16 AC 31 ms
25,028 KB
testcase_17 AC 32 ms
26,828 KB
testcase_18 AC 31 ms
27,188 KB
testcase_19 AC 31 ms
24,784 KB
testcase_20 AC 30 ms
26,952 KB
testcase_21 AC 30 ms
24,780 KB
testcase_22 AC 29 ms
25,036 KB
testcase_23 AC 28 ms
24,788 KB
testcase_24 AC 30 ms
24,784 KB
testcase_25 AC 31 ms
25,172 KB
testcase_26 AC 31 ms
24,912 KB
testcase_27 AC 28 ms
24,724 KB
testcase_28 AC 29 ms
24,896 KB
testcase_29 AC 31 ms
27,328 KB
testcase_30 AC 31 ms
25,032 KB
testcase_31 AC 31 ms
25,148 KB
testcase_32 AC 31 ms
24,912 KB
testcase_33 AC 33 ms
25,044 KB
testcase_34 AC 34 ms
26,948 KB
testcase_35 AC 29 ms
25,036 KB
testcase_36 AC 30 ms
25,008 KB
testcase_37 AC 30 ms
24,788 KB
testcase_38 AC 32 ms
27,084 KB
testcase_39 AC 29 ms
23,216 KB
testcase_40 AC 30 ms
26,952 KB
testcase_41 AC 30 ms
24,776 KB
testcase_42 AC 30 ms
24,892 KB
testcase_43 AC 30 ms
24,916 KB
testcase_44 AC 29 ms
26,952 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.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long num = long.Parse(Reader.ReadLine());
        Dictionary<long, long> tmp = this.CreateDic(num);
        long ans = num;
        if(tmp.ContainsKey(2) && tmp[2] >= 2) {
            ans = 4;
        }
        if(tmp.Keys.Count(a=>a>2)>0) {
            ans = Math.Min(ans, tmp.Keys.Where(a=>a>2).Min());
        }
        Console.WriteLine(ans);
    }
    
    private Dictionary<long, long> CreateDic(long num) {
        long tmp = num;
        Dictionary<long, long> ret = new Dictionary<long, long>();
        for(long i=2; i*i<=num; i++) {
            while (tmp % i == 0)
            {
                if(ret.ContainsKey(i)) {
                    ret[i]++;
                } else {
                    ret.Add(i, 1);
                }
                if(i > 2) {
                    return ret;
                }
                tmp = tmp / i;
            }
            if(tmp == 1) {
                break;
            }
        }
        if(tmp > 1) {
            ret.Add(tmp, 1);
        }
        return ret;
        
    }
    
    
    


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"



4


 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0