結果
| 問題 |
No.791 うし数列
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2019-02-22 21:43:41 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 708 bytes |
| コンパイル時間 | 3,855 ms |
| コンパイル使用メモリ | 74,628 KB |
| 実行使用メモリ | 54,204 KB |
| 最終ジャッジ日時 | 2024-11-25 06:44:32 |
| 合計ジャッジ時間 | 6,528 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 WA * 5 |
ソースコード
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
static public void main(String[]args) throws Exception {
Scanner sc = new Scanner(System.in);
String n = sc.next();
printAns(n);
}
static void printAns(String s) throws Exception {
if( isValid(s) ) {
int ans = s.length() -1;
System.out.println(ans);
} else {
System.out.println(-1);
}
}
static boolean isValid(String s) throws Exception {
List<Character> list = new ArrayList<>();
for(int i=0; i<s.length(); i++) {
char c = s.charAt(i);
if(c == '1' || c == '3') {
//nothing
} else {
list.add(c);
}
}
if(list.size() == 0) return true;
return false;
}
}
kohaku_kohaku