結果

問題 No.1455 拡張ROTN
ユーザー bluemegane
提出日時 2021-04-01 14:31:17
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,365 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 113,248 KB
実行使用メモリ 25,692 KB
最終ジャッジ日時 2024-12-17 18:38:13
合計ジャッジ時間 2,138 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other RE * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    public static string x0 = "CpCzNkSuTbEoA";
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        var n = int.Parse(Console.ReadLine().Trim());
        getAns(s, n);
    }
    static void getAns (string s, int n)
    {
        var ans = "";
        var n26 = n % 26;
        foreach(var  x in s)
        {
            int tp;
            if (int.TryParse(x.ToString(), out tp)) ans += changeN(tp, n);
            else ans += changeC(x, n26);
        }
        Console.WriteLine(ans);
    }
    static string changeN (int t  , int a)
    {
        if (t + a <= 9) return (t + a).ToString();
        else
        {
            var ans = "";
            var a2 = (t + a - 10) % 26;
            foreach(var x in x0)
            {
                ans += changeC(x, a2); 
            }
            return ans;
        }
    }
    static string changeC(char t, int a )
    {
        var s = "abcdefghijklmnopqrstuvwxyz";
        var s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        if (char.IsUpper(t))
        {
            var sh = t - 'A';
            sh += a;
            if (sh >= 26) sh -= 26;
            return s2[sh].ToString();
        }
        else
        {
            var sh = t - 'a';
            sh += a;
            if (sh >= 26) sh -= 26;
            return s[sh].ToString();
        }
    }
}
0