結果
問題 | No.104 国道 |
ユーザー |
|
提出日時 | 2016-04-01 03:43:04 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 131 ms / 5,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 2,217 ms |
コンパイル使用メモリ | 74,596 KB |
実行使用メモリ | 41,436 KB |
最終ジャッジ日時 | 2024-10-02 08:44:42 |
合計ジャッジ時間 | 5,391 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
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);}}}