結果
| 問題 |
No.104 国道
|
| コンテスト | |
| ユーザー |
SagToki
|
| 提出日時 | 2018-05-16 14:39:16 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,624 bytes |
| コンパイル時間 | 3,702 ms |
| コンパイル使用メモリ | 77,280 KB |
| 実行使用メモリ | 41,504 KB |
| 最終ジャッジ日時 | 2024-06-28 13:18:31 |
| 合計ジャッジ時間 | 7,078 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 16 |
ソースコード
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.InputMismatchException;
public class NationalHighway {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
try{
String string = scanner.next();
if(string.length() != 0){
//Pattern pattern = Pattern.compile("*[R|L|^$]*");
Pattern pattern = Pattern.compile(".*[R|L].*");
Matcher matcher = pattern.matcher(string);
if(!matcher.find()){
System.out.println("文字列はRかLだけで入力してください");
System.exit(0);
}
if(string.length()<0 || string.length() > 30){
System.out.println("文字列は1以上30以下で入力してください");
}
}
int Road = 1;
char[] NewString = string.toCharArray();
for(int i = 0 ; i < string.length() ; i++){
System.out.print("test");
if(NewString[i] == 'R'){
Road = Road * 2 + 1;
}else if(NewString[i] == 'L'){
Road = Road * 2 ;
}else{
//何もしない
}
}
System.out.println(Road);
}catch(InputMismatchException e){
System.out.println("");
}catch(Exception E){
System.out.println("予期せぬエラーです");
}
}
}
SagToki