結果

問題 No.18 うーさー暗号
ユーザー fujitafujita
提出日時 2023-04-27 09:42:06
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 1,571 bytes
コンパイル時間 7,665 ms
コンパイル使用メモリ 166,212 KB
実行使用メモリ 183,112 KB
最終ジャッジ日時 2024-04-28 05:30:31
合計ジャッジ時間 9,261 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
27,008 KB
testcase_01 AC 48 ms
27,136 KB
testcase_02 AC 48 ms
27,136 KB
testcase_03 AC 50 ms
27,264 KB
testcase_04 AC 48 ms
27,264 KB
testcase_05 AC 48 ms
27,136 KB
testcase_06 AC 50 ms
27,264 KB
testcase_07 AC 48 ms
27,260 KB
testcase_08 AC 49 ms
27,136 KB
testcase_09 AC 51 ms
27,260 KB
testcase_10 AC 47 ms
27,264 KB
testcase_11 AC 47 ms
27,116 KB
testcase_12 AC 48 ms
183,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;

namespace yukicoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var X = Console.ReadLine();
            int i, c, e, d;
            List<string> list = new List<string>() { "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"};
             
            var z = X.Split(" ");
            string[] str = new string[X.Length];
            //文字分割
            for (int j = 0; j < X.Length; j++)
            {
                str[j] = z[0].Substring(j , 1);
            }

            
            for(i = 1; i <= X.Length; i++) 
            {
                
                //int e = 0;
                //int d = 0;
                c = list.IndexOf(str[i - 1]) + 1;//アルファベットの要素番号取得
                d = c - i;//アルファベットの要素番号から文字列iを引く
                e = (d - 1) % 26;//要素の中身がほしいアルファベット
               
                if(e < 0)
                {
                    e = e * -1;
                    int ans = (26 - e) % 26; 
                    Console.Write(list[ans]);
                }
                else
                {
                    Console.Write(list[e]);
                }
                
            }
        }
    }
}
0