結果
| 問題 |
No.1140 EXPotentiaLLL!
|
| ユーザー |
|
| 提出日時 | 2020-08-07 09:16:21 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,772 ms / 2,000 ms |
| コード長 | 740 bytes |
| コンパイル時間 | 2,208 ms |
| コンパイル使用メモリ | 74,764 KB |
| 実行使用メモリ | 66,096 KB |
| 最終ジャッジ日時 | 2024-09-22 17:25:07 |
| 合計ジャッジ時間 | 20,982 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 |
ソースコード
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
boolean nonp[] = new boolean[5000001];
nonp[1] = true;
for(int i = 2; i < 5000001; i++){
if(nonp[i]) continue;
for(int j = i+i; j < 5000001; j += i){
nonp[j] = true;
}
}
int t = Integer.parseInt(br.readLine());
while(t-- > 0){
String[] line = br.readLine().split(" ");
long a = Long.parseLong(line[0]);
int p = Integer.parseInt(line[1]);
System.out.println(nonp[p] ? -1 : a%p==0 ? 0 : 1);
}
}
}