結果

問題 No.18 うーさー暗号
ユーザー huffman56huffman56
提出日時 2022-04-16 21:04:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,257 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 110,668 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-12-25 23:35:30
合計ジャッジ時間 3,133 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;

namespace yukicoder
{
    class Program
    {
        static void Main()
        {

            // アルファベットを全て管理する変数
            string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string n = Console.ReadLine().Trim();

            // カウント変数
            int cnt = 0;
            // チェック変数
            int chk = 0;

            // 変換したアルファベットを格納する変数
            string[] ans = new string[n.Length];

            for (int i = 0; i < n.Length; i++)
            {
                chk = s.IndexOf(n[i]);
                // 何番目の文字列か
                int num = i % 26;

                // 該当の文字を格納
                ans[i] =
                    (chk - (num)) <= 0 ?
                        s[chk - (num+1) + 26].ToString() : s[chk - (num+1)].ToString(); 
            }

            Console.WriteLine(String.Join("" , ans));
        }
    }
}
0