結果

問題 No.18 うーさー暗号
ユーザー meme
提出日時 2023-05-02 13:16:54
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 3,653 ms
コンパイル使用メモリ 32,148 KB
実行使用メモリ 32,660 KB
最終ジャッジ日時 2024-05-01 03:40:46
合計ジャッジ時間 5,087 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$s = trim(fgets(STDIN));
$s = str_split($s, 1);

$alphabet = [
    'A' => 1,
    'B' => 2,
    'C' => 3,
    'D' => 4,
    'E' => 5,
    'F' => 6,
    'G' => 7,
    'H' => 8,
    'I' => 9,
    'J' => 10,
    'K' => 11,
    'L' => 12,
    'M' => 13,
    'N' => 14,
    'O' => 15,
    'P' => 16,
    'Q' => 17,
    'R' => 18,
    'S' => 19,
    'T' => 20,
    'U' => 21,
    'V' => 22,
    'W' => 23,
    'X' => 24,
    'Y' => 25,
    'Z' => 26
];

$answer = '';
for($i = 0; $i < count($s); $i++){
    $char = $s[$i];
    $char_num = $alphabet[$char];

    if($i + 1 > 26){
        $char_num = $char_num - (($i + 1) % 26);
    } else {
        $char_num = $char_num - ($i + 1);
    }
    
    foreach($alphabet as $key => $value){
        if($char_num === $value){
            $answer .= $key;
        }
    }
}

echo $answer, "/n";
0