結果

問題 No.18 うーさー暗号
ユーザー changta_15changta_15
提出日時 2019-09-02 23:51:16
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 1,236 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 105,524 KB
実行使用メモリ 22,544 KB
最終ジャッジ日時 2023-08-22 19:33:47
合計ジャッジ時間 3,843 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
20,512 KB
testcase_01 AC 49 ms
18,500 KB
testcase_02 AC 51 ms
20,600 KB
testcase_03 AC 51 ms
20,612 KB
testcase_04 AC 51 ms
20,664 KB
testcase_05 AC 51 ms
22,536 KB
testcase_06 AC 51 ms
22,544 KB
testcase_07 AC 50 ms
20,492 KB
testcase_08 AC 51 ms
22,524 KB
testcase_09 AC 51 ms
20,440 KB
testcase_10 AC 52 ms
20,560 KB
testcase_11 AC 51 ms
20,552 KB
testcase_12 AC 50 ms
20,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
namespace test9002
{
    class Program
    {
        public static readonly int alphaCount = 26;
        public static readonly char[] alphas = 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' };

        static void Main()
        {
            var arg = Console.ReadLine().Trim();
            char tempChar = 'a';
            int charOrder = 0;
            string outputWord = "";
            int reverseCount = 0;
            for (int i = 0; i < arg.Length; i++)
            {
                tempChar = arg[i];
                charOrder = Array.IndexOf(alphas, tempChar);
                reverseCount = (i + 1) % alphaCount;
                if ((charOrder - reverseCount) >= 0)
                {
                    outputWord += alphas[charOrder - reverseCount];
                }
                else if ((charOrder - reverseCount) < 0)
                {
                    outputWord += alphas[charOrder - reverseCount + 26];
                }
                else
                {
                    outputWord += tempChar;
                }
            }
            Console.WriteLine(outputWord);
        }
    }
}
0