結果

問題 No.791 うし数列
ユーザー GrenacheGrenache
提出日時 2019-04-26 15:15:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 2,941 ms
コンパイル使用メモリ 75,252 KB
実行使用メモリ 41,656 KB
最終ジャッジ日時 2024-05-03 12:37:55
合計ジャッジ時間 5,453 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
41,616 KB
testcase_01 AC 100 ms
40,772 KB
testcase_02 AC 111 ms
41,176 KB
testcase_03 AC 110 ms
41,356 KB
testcase_04 AC 108 ms
41,612 KB
testcase_05 AC 108 ms
41,044 KB
testcase_06 AC 108 ms
40,780 KB
testcase_07 AC 94 ms
41,268 KB
testcase_08 AC 113 ms
41,212 KB
testcase_09 AC 111 ms
41,336 KB
testcase_10 AC 101 ms
41,364 KB
testcase_11 AC 112 ms
40,416 KB
testcase_12 AC 108 ms
40,024 KB
testcase_13 AC 110 ms
41,656 KB
testcase_14 AC 105 ms
41,388 KB
testcase_15 AC 109 ms
41,264 KB
testcase_16 AC 102 ms
41,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder791 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] n = sc.next().toCharArray();

		if (n[0] != '1' || n.length == 1) {
			pr.println(-1);
			return;
		}
		
		for (int i = 1, size = n.length; i < size; i++) {
			if (n[i] != '3') {
				pr.println(-1);
				return;
			}
		}
		
		pr.println(n.length - 1);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0