結果

問題 No.136 Yet Another GCD Problem
ユーザー 14番14番
提出日時 2016-04-18 07:57:40
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,347 bytes
コンパイル時間 933 ms
コンパイル使用メモリ 114,244 KB
実行使用メモリ 26,164 KB
最終ジャッジ日時 2024-04-15 03:26:04
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,860 KB
testcase_01 AC 25 ms
23,836 KB
testcase_02 AC 25 ms
24,112 KB
testcase_03 AC 25 ms
24,112 KB
testcase_04 WA -
testcase_05 AC 25 ms
24,092 KB
testcase_06 WA -
testcase_07 AC 24 ms
23,784 KB
testcase_08 AC 27 ms
26,020 KB
testcase_09 AC 25 ms
23,848 KB
testcase_10 WA -
testcase_11 AC 26 ms
26,164 KB
testcase_12 WA -
testcase_13 AC 26 ms
24,096 KB
testcase_14 AC 27 ms
26,000 KB
testcase_15 WA -
testcase_16 AC 27 ms
24,136 KB
testcase_17 AC 26 ms
21,808 KB
testcase_18 AC 25 ms
25,748 KB
testcase_19 AC 26 ms
24,080 KB
testcase_20 AC 24 ms
23,964 KB
testcase_21 AC 24 ms
23,980 KB
testcase_22 AC 25 ms
25,896 KB
testcase_23 AC 25 ms
23,984 KB
testcase_24 AC 24 ms
24,240 KB
testcase_25 AC 24 ms
26,148 KB
testcase_26 AC 25 ms
24,088 KB
testcase_27 AC 26 ms
23,956 KB
testcase_28 AC 24 ms
24,116 KB
testcase_29 AC 24 ms
23,964 KB
testcase_30 AC 24 ms
26,128 KB
testcase_31 AC 23 ms
24,092 KB
testcase_32 AC 24 ms
24,212 KB
testcase_33 AC 24 ms
24,088 KB
testcase_34 AC 25 ms
25,980 KB
testcase_35 AC 24 ms
24,088 KB
testcase_36 AC 25 ms
24,236 KB
testcase_37 AC 26 ms
23,828 KB
testcase_38 AC 24 ms
24,112 KB
testcase_39 AC 24 ms
23,832 KB
testcase_40 AC 25 ms
23,852 KB
testcase_41 AC 24 ms
23,972 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;
        int[] inpt = Reader.GetInt();
        int total = inpt[0];
        int maxItemCount = inpt[1];
        
        this.CreatePrimeNumberList(total);
        int ans = 1;
        if(total % 2 == 0) {
            ans = total / 2;
        } else
        {
            foreach (int num in PrimeNumberList)
            {
                if(total % num == 0) {
                    int tmp = total / num;
                    ans = tmp * (num / 2);
                    break;
                }
            }
            
        }
        Console.WriteLine(ans);
    }
    
    private List<int> PrimeNumberList = new List<int>();
    
    private void CreatePrimeNumberList(int max) {
        bool[] flags = new bool[max+1];
        List<int> list = new List<int>();
        
        for(int i=2; i<max; i++) {
            if(!flags[i]) {
                list.Add(i);
                for(int j=1; j<=max/i; j++) {
                    flags[i*j] = true;
                }
            }
        }
        this.PrimeNumberList = list;
    }

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


21 2


 
";
        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();
            }
        }
        public static int[] GetInt(char delimiter = ' ', bool trim = false)
        {
            string inptStr = ReadLine();
            if (trim)
            {
                inptStr = inptStr.Trim();
            }
            string[] inpt = inptStr.Split(delimiter);
            int[] ret = new int[inpt.Length];
            for (int i = 0; i < inpt.Length; i++)
            {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0