結果

問題 No.1047 Zero (Novice)
ユーザー xRS43BofaUEZ5gc
提出日時 2021-03-29 14:57:41
言語 Java
(openjdk 23)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 5,092 ms
コンパイル使用メモリ 75,396 KB
実行使用メモリ 41,716 KB
最終ジャッジ日時 2024-11-29 09:49:19
合計ジャッジ時間 7,166 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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