結果

問題 No.18 うーさー暗号
ユーザー n.yn.y
提出日時 2022-06-03 14:44:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,953 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 108,532 KB
実行使用メモリ 23,596 KB
最終ジャッジ日時 2023-10-21 01:28:32
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
23,596 KB
testcase_01 AC 22 ms
23,596 KB
testcase_02 AC 22 ms
23,596 KB
testcase_03 AC 26 ms
23,576 KB
testcase_04 AC 23 ms
23,596 KB
testcase_05 AC 24 ms
23,596 KB
testcase_06 AC 24 ms
23,596 KB
testcase_07 AC 25 ms
23,596 KB
testcase_08 AC 25 ms
23,596 KB
testcase_09 AC 24 ms
23,596 KB
testcase_10 AC 23 ms
23,596 KB
testcase_11 AC 24 ms
23,596 KB
testcase_12 AC 25 ms
23,596 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.Diagnostics;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //文字列入力
            string S = Console.ReadLine();

            string[] a = { "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" };
            //入力した配列
            string[] s = new string[S.Length];

            //文字列の一部分の取得
            for (int i = 0; i < S.Length; i++)
            {
                string str = S.Substring(i, 1);
                s[i] = str;
            }
            //26を何回するか
            int x = S.Length / 26;
            //一文字とる 
            for (int i=1;i<=S.Length;i++)
            {
                for (int j = 1; j <= a.Length; j++)
                {
                    //アルファベットから数値にする
                    if (s[i - 1] == a[j-1])
                    {
                        //数値求める
                        int c = j - i;
                        //26足す回数
                        for (int k = 0; k < x+1; k++)
                        {
                            if (c <= 0)
                            {
                                c += 26;
                            }
                            if(c>0&&c>=26)
                            {
                                break;
                            }
                        }
                        //数値の数だけアルファベット移動させる,
                        s[i - 1] = a[c-1];
                        Debug.WriteLine(s[i - 1]);
                        break;
                    }


                }
                
            }
            //表示
            for (int i = 1; i <= S.Length; i++)
            {
                Console.Write(s[i-1]);

            }

        }
    }
}
0