結果
| 問題 | No.791 うし数列 |
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2019-02-22 21:53:22 |
| 言語 | Java (openjdk 27 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 55 ms / 2,000 ms |
| + 73µs | |
| コード長 | 610 bytes |
| 記録 | |
| コンパイル時間 | 1,512 ms |
| コンパイル使用メモリ | 85,924 KB |
| 実行使用メモリ | 45,396 KB |
| 最終ジャッジ日時 | 2026-09-29 18:34:25 |
| 合計ジャッジ時間 | 3,926 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
ソースコード
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 {
if(s.charAt(0) != '1') return false;
if(!s.contains("3")) return false;
for(int i=1; i<s.length(); i++) {
char c = s.charAt(i);
if( c != '3') return false;
}
return true;
}
}
kohaku_kohaku