結果

問題 No.104 国道
ユーザー sorchsorch
提出日時 2021-01-01 08:53:29
言語 PHP
(8.3.4)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 412 bytes
コンパイル時間 3,209 ms
コンパイル使用メモリ 30,660 KB
実行使用メモリ 31,412 KB
最終ジャッジ日時 2024-04-19 02:53:19
合計ジャッジ時間 1,727 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
31,412 KB
testcase_01 AC 39 ms
30,900 KB
testcase_02 AC 39 ms
30,984 KB
testcase_03 AC 38 ms
31,012 KB
testcase_04 AC 39 ms
31,224 KB
testcase_05 AC 39 ms
31,132 KB
testcase_06 AC 39 ms
30,932 KB
testcase_07 AC 40 ms
31,372 KB
testcase_08 AC 39 ms
31,256 KB
testcase_09 AC 37 ms
31,280 KB
testcase_10 AC 38 ms
31,216 KB
testcase_11 AC 38 ms
30,960 KB
testcase_12 AC 38 ms
30,876 KB
testcase_13 AC 37 ms
30,840 KB
testcase_14 AC 37 ms
31,312 KB
testcase_15 AC 39 ms
31,272 KB
testcase_16 AC 38 ms
31,080 KB
testcase_17 AC 38 ms
31,328 KB
testcase_18 AC 38 ms
31,004 KB
testcase_19 AC 38 ms
31,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

/**
 * @see https://yukicoder.me/problems/no/104
 */

$S = str_split(trim(fgets(STDIN)));

$currentLocation = 1;
foreach ($S as $directionHistory) {
    switch ($directionHistory) {
        case 'L':
            $currentLocation = $currentLocation * 2;
            break;
        case 'R':
            $currentLocation = $currentLocation * 2 + 1;
            break;
    }
}

echo $currentLocation . "\n";
0