結果

問題 No.104 国道
ユーザー 37zigen37zigen
提出日時 2016-04-01 03:43:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 74,412 KB
実行使用メモリ 54,376 KB
最終ジャッジ日時 2024-04-10 07:01:49
合計ジャッジ時間 5,148 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
53,668 KB
testcase_01 AC 113 ms
54,000 KB
testcase_02 AC 116 ms
54,008 KB
testcase_03 AC 114 ms
53,852 KB
testcase_04 AC 104 ms
52,972 KB
testcase_05 AC 116 ms
53,952 KB
testcase_06 AC 119 ms
54,116 KB
testcase_07 AC 122 ms
54,112 KB
testcase_08 AC 117 ms
54,108 KB
testcase_09 AC 118 ms
54,368 KB
testcase_10 AC 118 ms
54,184 KB
testcase_11 AC 117 ms
54,100 KB
testcase_12 AC 116 ms
54,176 KB
testcase_13 AC 108 ms
53,568 KB
testcase_14 AC 118 ms
53,984 KB
testcase_15 AC 120 ms
54,080 KB
testcase_16 AC 119 ms
54,376 KB
testcase_17 AC 116 ms
54,056 KB
testcase_18 AC 118 ms
54,152 KB
testcase_19 AC 113 ms
54,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder104;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		int low=1;
		int upper=(int)Math.pow(2,str.length());
		for(int i=0;i<str.length();i++){

			if(str.charAt(i)=='L'){
				upper=(upper+low)/2;
//				System.err.println("upper"+upper);
//				System.err.println("low"+low);
			}else if(str.charAt(i)=='R'){
				low=(upper+low)/2+1;
				
//				System.err.println("upper"+upper);
//				System.err.println("low"+low);
			}
		}
		if(low!=upper){
			System.err.println("error");
		}
		if(str.length()>=1){
			System.out.println((int)Math.pow(2, str.length())-1+low);
		}else if(str.length()==0){
			System.out.println(1);
		}
	}
}
0