結果

問題 No.327 アルファベット列
ユーザー bayashiko_rbayashiko_r
提出日時 2019-01-07 02:07:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,209 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 100,532 KB
実行使用メモリ 27,164 KB
最終ジャッジ日時 2023-08-15 16:23:58
合計ジャッジ時間 7,386 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        int kari = N;

        //桁数を数える
        int digit = 1;
        int sum = 0;

        //A~Zの配列
        char[] let = new char[26] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

        for (int i = 0; i < N; i++) {
            sum += (int)Math.Pow(26, i + 1);
            if (N < sum) {
                break;
            }
            kari -= (int)Math.Pow(26, i + 1);
            digit++;
        }

        
        Console.WriteLine(digit);

        //回答となる文字列
        char[] ans = new char[digit];

        ans[digit - 1] = let[kari % 26];  //一番下のケタ

        //各桁を調べていく(最初のケタ~下から二桁目まで)
        for (int i = 0; i <= digit - 2; i++) {
            ans[i] = let[kari / (int)Math.Pow(26, digit - i)];
            kari -= kari * 26 / (int)Math.Pow(26, digit - i - 1);
        }

        //出力
        for (int i = 0; i < digit; i++) {
            Console.Write(ans[i]);
        }
    }
}
0