結果

問題 No.1047 Zero (Novice)
ユーザー xRS43BofaUEZ5gcxRS43BofaUEZ5gc
提出日時 2021-03-29 14:57:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 2,956 ms
コンパイル使用メモリ 72,484 KB
実行使用メモリ 56,540 KB
最終ジャッジ日時 2023-08-19 16:10:42
合計ジャッジ時間 6,489 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,736 KB
testcase_01 AC 118 ms
55,804 KB
testcase_02 AC 118 ms
56,040 KB
testcase_03 AC 118 ms
55,868 KB
testcase_04 AC 118 ms
55,784 KB
testcase_05 AC 117 ms
55,724 KB
testcase_06 AC 118 ms
55,860 KB
testcase_07 AC 117 ms
55,960 KB
testcase_08 AC 117 ms
55,788 KB
testcase_09 AC 117 ms
56,076 KB
testcase_10 AC 117 ms
56,540 KB
testcase_11 AC 117 ms
55,968 KB
testcase_12 AC 116 ms
55,496 KB
testcase_13 AC 118 ms
55,932 KB
testcase_14 AC 117 ms
55,944 KB
testcase_15 AC 116 ms
55,788 KB
testcase_16 AC 120 ms
55,808 KB
testcase_17 AC 118 ms
55,912 KB
testcase_18 AC 119 ms
55,920 KB
testcase_19 AC 119 ms
55,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class HelloWorld {
		public static void main (String[] args) {
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			sc.close();
			int temp = 0;

			if (a > 0 && b > 0) {
				System.out.println(-1);
			}else {
				for (int i = 0;i < 1000 ; i ++) {
					temp = a * temp + b;
					if (temp == 0) {
						System.out.println(i + 1);
						break;
					}
					if (i == 999) {System.out.println(-1);}
				}
			}


	}
}
0