結果

問題 No.164 ちっちゃくないよ!!
ユーザー 明智重蔵明智重蔵
提出日時 2015-08-28 22:03:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 3,092 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 110,796 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-04-21 15:27:07
合計ジャッジ時間 2,264 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
19,072 KB
testcase_01 AC 27 ms
19,072 KB
testcase_02 AC 27 ms
19,072 KB
testcase_03 AC 26 ms
19,328 KB
testcase_04 AC 28 ms
19,200 KB
testcase_05 AC 31 ms
19,456 KB
testcase_06 AC 29 ms
19,328 KB
testcase_07 AC 28 ms
19,200 KB
testcase_08 AC 28 ms
19,200 KB
testcase_09 AC 28 ms
19,072 KB
testcase_10 AC 26 ms
19,200 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.Linq;

class Program
{
    static string InputPattern = "Input5";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4");
            WillReturn.Add("41");
            WillReturn.Add("32");
            WillReturn.Add("23");
            WillReturn.Add("14");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("9");
            WillReturn.Add("000223444444");
            WillReturn.Add("00003641077");
            WillReturn.Add("0001783660");
            WillReturn.Add("00002DOOO");
            WillReturn.Add("00052KC0");
            WillReturn.Add("0064JJJ");
            WillReturn.Add("0BG938");
            WillReturn.Add("F423F");
            WillReturn.Add("UGHV");
            //999999
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("7");
            WillReturn.Add("YUKICODER");
            WillReturn.Add("TOPCODER");
            WillReturn.Add("ATCODER");
            WillReturn.Add("CODEFORCES");
            WillReturn.Add("CODECHEF");
            WillReturn.Add("AIZUONLINE");
            WillReturn.Add("HACKERRANK");
            //8005080147
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("1");
            WillReturn.Add("0XFFFFFFFFFF");
            //69062819408545233
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string[] VArr = InputList.Skip(1).ToArray();

        //foreach (string EachStr in VArr) {
        //    Console.WriteLine(DeriveVal(EachStr));
        //}

        Console.WriteLine(VArr.Min(X => DeriveVal(X)));
    }

    //解釈できるうちで最小の数を、Decimal型で返す
    static decimal DeriveVal(string pTarget)
    {
        int ShinSuu = DeriveShinSuu(pTarget);
        //Console.WriteLine("{0}は{1}進数", pTarget, ShinSuu);

        decimal WillReturn = 0;

        for (int I = 0; I <= pTarget.Length - 1; I++) {
            char CurrChar = pTarget[pTarget.Length - 1 - I];
            int CurrInt;
            if (CurrChar <= '9') CurrInt = CurrChar - '0';
            else CurrInt = CurrChar - 'A' + 10;

            WillReturn += DeriveBekijyou(CurrInt, ShinSuu, I);
        }
        return WillReturn;
    }

    //何進数かを求める
    static int DeriveShinSuu(string pTarget)
    {
        //最大の文字
        char MaxChar = pTarget.Max();

        if (MaxChar <= '9')
            return MaxChar - '0' + 1;
        return MaxChar - 'A' + 10 + 1;
    }

    //X*(AのN乗)をDecimal型で返す
    static decimal DeriveBekijyou(int pX, int pA, int pN)
    {
        decimal WillReturn = pX;

        for (int I = 1; I <= pN; I++) {
            WillReturn *= pA;
        }
        return WillReturn;
    }
}
0