結果
| 問題 | 
                            No.104 国道
                             | 
                    
| コンテスト | |
| ユーザー | 
                             YamaKasa
                         | 
                    
| 提出日時 | 2018-04-24 03:56:06 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 622 bytes | 
| コンパイル時間 | 1,967 ms | 
| コンパイル使用メモリ | 74,296 KB | 
| 実行使用メモリ | 56,336 KB | 
| 最終ジャッジ日時 | 2024-06-27 15:48:43 | 
| 合計ジャッジ時間 | 5,285 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 WA * 1 | 
| other | AC * 5 WA * 11 | 
ソースコード
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		scan.close();
		if(s.length() == 0) {
			System.out.println("1");
			System.exit(0);
		}
		int l = s.length();
		int h = (int)Math.pow(2, l);
		int k = 0;
		for(int i = 0; i < l; i++) {
			if(s.substring(i, i + 1).equals("R")) {
				if(k == 0) {
					k = 1;
				}else {
					k = (int)Math.pow(2, k) + 1;
				}
			}else {
				if(k == 0) {
					k = 0;
				}else {
					k = (int)Math.pow(2, k);
				}
			}
		}
		int ans = k + h;
		System.out.println(ans);
	}
}
            
            
            
        
            
YamaKasa