結果

問題 No.1140 EXPotentiaLLL!
ユーザー face4face4
提出日時 2020-08-07 09:16:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,690 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 74,624 KB
実行使用メモリ 72,468 KB
最終ジャッジ日時 2023-10-24 00:21:10
合計ジャッジ時間 20,438 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,690 ms
68,968 KB
testcase_01 AC 1,580 ms
66,032 KB
testcase_02 AC 1,596 ms
68,964 KB
testcase_03 AC 1,491 ms
72,468 KB
testcase_04 AC 1,239 ms
68,668 KB
testcase_05 AC 1,607 ms
68,992 KB
testcase_06 AC 1,548 ms
68,996 KB
testcase_07 AC 1,644 ms
69,160 KB
testcase_08 AC 113 ms
59,000 KB
testcase_09 AC 113 ms
59,020 KB
testcase_10 AC 113 ms
59,024 KB
testcase_11 AC 118 ms
59,108 KB
testcase_12 AC 111 ms
59,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
        }
    }
}
0