結果

問題 No.18 うーさー暗号
コンテスト
ユーザー aaa aa
提出日時 2025-11-28 16:10:55
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 1,079 bytes
コンパイル時間 8,596 ms
コンパイル使用メモリ 168,540 KB
実行使用メモリ 185,452 KB
最終ジャッジ日時 2025-11-28 16:11:11
合計ジャッジ時間 10,545 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #
raw source code

using System;
using System.Diagnostics;
public class Program
{
    public static void Main()
    {
        //int turn = int.Parse(Console.ReadLine() ?? string.Empty);
        //string[] num = (Console.ReadLine() ?? string.Empty).Trim().Split(' ');
        string str = Console.ReadLine() ?? string.Empty;

        string alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        string change = "";
        for(int i = 0; i < str.Length; i++)
        {
            int index = alph.IndexOf(str[i]);
            if(index - (i+1) < 0)
            {
                int aa = alph.Length + (index - (i + 1));
                while (aa < -26)
                {
                    aa = alph.Length + aa;
                }

                if(aa >= 0)
                {
                    change += alph[aa];
                }
                else
                {
                    change += alph[alph.Length + aa];

                }
            }
            else
            {
                change += alph[index - i-1];
            }

        }
        Console.WriteLine(change);

    }
}
0