結果

問題 No.791 うし数列
ユーザー YamaKasaYamaKasa
提出日時 2019-02-22 21:30:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 72,296 KB
実行使用メモリ 57,360 KB
最終ジャッジ日時 2023-08-16 15:42:18
合計ジャッジ時間 4,985 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,832 KB
testcase_01 AC 115 ms
56,008 KB
testcase_02 AC 117 ms
55,808 KB
testcase_03 AC 115 ms
55,364 KB
testcase_04 AC 117 ms
55,472 KB
testcase_05 AC 116 ms
56,076 KB
testcase_06 AC 116 ms
55,648 KB
testcase_07 AC 118 ms
55,424 KB
testcase_08 AC 118 ms
55,928 KB
testcase_09 AC 118 ms
57,360 KB
testcase_10 AC 116 ms
55,388 KB
testcase_11 AC 119 ms
55,812 KB
testcase_12 AC 117 ms
55,892 KB
testcase_13 AC 116 ms
55,932 KB
testcase_14 AC 117 ms
55,804 KB
testcase_15 AC 116 ms
55,344 KB
testcase_16 AC 116 ms
56,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		if(N.charAt(0) != '1' || N.length() == 1) {
			System.out.println(-1);
			System.exit(0);
		}
		for(int i = 1; i < N.length(); i++) {
			char c = N.charAt(i);
			if(c != '3') {
				System.out.println(-1);
				System.exit(0);
			}
		}
		System.out.println(N.length() - 1);
	}
}
0