結果

問題 No.104 国道
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-24 15:53:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 656 bytes
コンパイル時間 4,218 ms
コンパイル使用メモリ 71,504 KB
実行使用メモリ 49,820 KB
最終ジャッジ日時 2023-08-13 23:31:02
合計ジャッジ時間 5,132 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,188 KB
testcase_01 AC 42 ms
49,644 KB
testcase_02 AC 42 ms
49,112 KB
testcase_03 AC 40 ms
49,176 KB
testcase_04 AC 41 ms
49,236 KB
testcase_05 AC 42 ms
49,040 KB
testcase_06 AC 41 ms
49,416 KB
testcase_07 AC 41 ms
49,408 KB
testcase_08 AC 42 ms
49,152 KB
testcase_09 AC 42 ms
49,224 KB
testcase_10 AC 43 ms
49,312 KB
testcase_11 AC 42 ms
49,388 KB
testcase_12 AC 43 ms
49,344 KB
testcase_13 AC 42 ms
49,084 KB
testcase_14 AC 42 ms
49,148 KB
testcase_15 AC 41 ms
49,228 KB
testcase_16 AC 41 ms
49,308 KB
testcase_17 AC 40 ms
49,280 KB
testcase_18 AC 42 ms
49,280 KB
testcase_19 AC 42 ms
49,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;

public class No104{
    public static void main(String[] args) throws IOException{
        String str = new BufferedReader(new InputStreamReader(System.in)).readLine();
        if(str == null){
            System.out.println(1);
            return;
        }
        else{
            char[] direction = str.toCharArray();
            long roadNum = 1;
            System.out.println(calc(roadNum, direction));
        }
    }
     
    public static long calc(long a, char[] b){
        for(int i=0; i < b.length; i++){
            if(b[i] == 'R') a = (a * 2) + 1;
            if(b[i] == 'L') a *= 2;
        }
        return a;
    }
}
0