結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 CleyL
提出日時 2021-12-01 12:23:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,214 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 63,616 KB
実行使用メモリ 8,380 KB
最終ジャッジ日時 2024-07-04 11:53:11
合計ジャッジ時間 11,836 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
bool pri[5000001];
void init(){
    pri[0] = pri[1] = true;
    for(int i = 2; 5000001 > i; i++){
        if(!pri[i]){
            for(int j = i+i; 5000001 > j; j+=i){
                pri[j]=true;
            }
        }
    }
}
int main(){
    init();
    int t;cin>>t;
    for(int i = 0; t > i; i++){
        long long a;
        int p;cin>>a>>p;
        if(pri[p]){
            cout << -1 << "\n";
        }else if(!(a%(long long)p)){
            cout << 0 << "\n";
        }else{
            cout << 1 << "\n";
        }
        
    }
}
0