結果
| 問題 | No.791 うし数列 |
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2019-02-22 21:53:22 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 610 bytes |
| 記録 | |
| コンパイル時間 | 1,850 ms |
| コンパイル使用メモリ | 82,364 KB |
| 実行使用メモリ | 41,628 KB |
| 最終ジャッジ日時 | 2026-05-19 20:06:19 |
| 合計ジャッジ時間 | 4,001 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_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