結果
| 問題 | No.1047 Zero (Novice) |
| コンテスト | |
| ユーザー |
joybeeee
|
| 提出日時 | 2020-05-12 15:55:50 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 430 bytes |
| 記録 | |
| コンパイル時間 | 2,253 ms |
| コンパイル使用メモリ | 75,152 KB |
| 実行使用メモリ | 234,276 KB |
| 最終ジャッジ日時 | 2024-09-13 14:00:53 |
| 合計ジャッジ時間 | 7,027 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 TLE * 1 -- * 12 |
ソースコード
import java.util.*;
public class Main {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int n = 0;
Set<Integer> seen = new HashSet<>();
while(!seen.contains(n)) {
seen.add(n);
n = a * n + b;
}
System.out.println(n == 0 ? seen.size() : -1);
}
}
joybeeee