結果

問題 No.327 アルファベット列
ユーザー 明智重蔵明智重蔵
提出日時 2016-06-11 19:23:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 2,236 bytes
コンパイル時間 891 ms
コンパイル使用メモリ 106,624 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-17 18:52:55
合計ジャッジ時間 2,949 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
18,688 KB
testcase_01 AC 20 ms
18,944 KB
testcase_02 AC 20 ms
18,688 KB
testcase_03 AC 20 ms
18,560 KB
testcase_04 AC 20 ms
18,432 KB
testcase_05 AC 20 ms
18,816 KB
testcase_06 AC 21 ms
18,688 KB
testcase_07 AC 21 ms
18,816 KB
testcase_08 AC 20 ms
18,560 KB
testcase_09 AC 20 ms
18,560 KB
testcase_10 AC 22 ms
18,688 KB
testcase_11 AC 21 ms
18,816 KB
testcase_12 AC 20 ms
18,688 KB
testcase_13 AC 20 ms
18,944 KB
testcase_14 AC 20 ms
18,560 KB
testcase_15 AC 20 ms
18,560 KB
testcase_16 AC 20 ms
18,688 KB
testcase_17 AC 20 ms
18,432 KB
testcase_18 AC 20 ms
18,816 KB
testcase_19 AC 20 ms
18,816 KB
testcase_20 AC 19 ms
18,944 KB
testcase_21 AC 21 ms
18,688 KB
testcase_22 AC 20 ms
18,944 KB
testcase_23 AC 19 ms
18,688 KB
testcase_24 AC 20 ms
18,688 KB
testcase_25 AC 20 ms
18,560 KB
testcase_26 AC 20 ms
18,560 KB
testcase_27 AC 20 ms
18,560 KB
testcase_28 AC 20 ms
18,816 KB
testcase_29 AC 20 ms
18,560 KB
testcase_30 AC 21 ms
18,560 KB
testcase_31 AC 20 ms
18,304 KB
testcase_32 AC 20 ms
18,816 KB
testcase_33 AC 20 ms
18,688 KB
testcase_34 AC 20 ms
18,560 KB
testcase_35 AC 21 ms
18,816 KB
testcase_36 AC 21 ms
18,688 KB
testcase_37 AC 20 ms
18,816 KB
testcase_38 AC 20 ms
18,688 KB
testcase_39 AC 20 ms
18,944 KB
testcase_40 AC 20 ms
18,688 KB
testcase_41 AC 21 ms
18,816 KB
testcase_42 AC 21 ms
18,816 KB
testcase_43 AC 20 ms
18,560 KB
testcase_44 AC 20 ms
18,688 KB
testcase_45 AC 21 ms
18,688 KB
testcase_46 AC 20 ms
18,688 KB
testcase_47 AC 20 ms
18,816 KB
testcase_48 AC 20 ms
18,688 KB
testcase_49 AC 20 ms
18,560 KB
testcase_50 AC 20 ms
18,816 KB
testcase_51 AC 20 ms
18,688 KB
testcase_52 AC 20 ms
18,688 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;

//No.327 アルファベット列
class Program
{
    static string InputPattern = "InputX";

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

        if (InputPattern == "Input1") {
            WillReturn.Add("0");
            //A
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("25");
            //Z
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("26");
            //AA
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long N = long.Parse(InputList[0]);

        Solve(N);
    }

    static void Solve(long pN)
    {
        long ZentaiBanme = pN + 1; //全体の何番目を求めるか

        //群ごとの項数を求める
        long CurrGunCnt = 26;
        var GunKousuuList = new List<long>();
        while (true) {
            GunKousuuList.Add(CurrGunCnt);
            if (GunKousuuList.Sum() > ZentaiBanme) break;
            CurrGunCnt *= 26;
        }

        long RunSum = 0;
        long GunBanme = ZentaiBanme; //対象群の何番目を求めるか
        long TargetGunLength = 1;
        for (int I = 0; I <= GunKousuuList.Count - 1; I++) {
            RunSum += GunKousuuList[I];
            if (ZentaiBanme <= RunSum) {
                TargetGunLength = I + 1;
                break;
            }
            GunBanme -= GunKousuuList[I];
        }

        long TargetNum = GunBanme - 1;
        var NumList = new List<long>();
        do {
            NumList.Add(TargetNum % 26);
            TargetNum /= 26;
        } while (TargetNum > 0);
        while (NumList.Count < TargetGunLength) NumList.Add(0);
        NumList.Reverse();

        var sb = new System.Text.StringBuilder();
        int UB = NumList.Count - 1;
        for (int I = 0; I <= UB; I++) {
            char wkChar = (char)('A' + (char)NumList[I]);
            sb.Append(wkChar);
        }
        Console.WriteLine(sb.ToString());
    }
}
0