結果
問題 |
No.1455 拡張ROTN
|
ユーザー |
![]() |
提出日時 | 2021-05-06 18:22:13 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-09-14 09:31:06 |
合計ジャッジ時間 | 3,741 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
S = gets.chomp N = gets.to_i def g(s, n) res = s n.times do res = f(res, 1) end res end def f(s, n) return s if n <= 0 ans = '' queue = s.chars until queue.empty? s = queue.shift case s when 'a'..'z' ans << ('a'.ord + (s.ord - 'a'.ord + n) % 26).chr when 'A'..'Z' ans << ('A'.ord + (s.ord - 'A'.ord + n) % 26).chr else d = s.to_i if d + n >= 10 ans << 'CpCzNkSuTbEoA' else ans << (d + n).to_s end end end ans end a = [N, 10].min r = N - a puts f(g(S, a), r)