結果

問題 No.1140 EXPotentiaLLL!
ユーザー green+green+
提出日時 2020-08-01 00:28:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,286 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 81,368 KB
実行使用メモリ 22,620 KB
最終ジャッジ日時 2023-09-21 04:13:12
合計ジャッジ時間 13,083 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,240 ms
22,620 KB
testcase_01 AC 1,286 ms
22,496 KB
testcase_02 AC 1,257 ms
22,548 KB
testcase_03 AC 969 ms
22,444 KB
testcase_04 AC 752 ms
22,544 KB
testcase_05 AC 1,164 ms
22,500 KB
testcase_06 AC 1,104 ms
22,440 KB
testcase_07 AC 1,247 ms
22,328 KB
testcase_08 AC 93 ms
22,272 KB
testcase_09 AC 91 ms
22,544 KB
testcase_10 AC 93 ms
22,520 KB
testcase_11 AC 92 ms
22,348 KB
testcase_12 AC 91 ms
22,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    long long t,k,a,p,n=5000010;
    vector<int>r(n,1);r[0]=0;r[1]=0;
    rep(i,n){
        if(r[i]==1){
            k=i*2;
            while(k<n){
                r[k]=0;
                k+=i;
            }
        }
    }
    cin>>t;
    rep(i,t){
        cin>>a>>p;
        if(r[p]){
            if(a%p)cout<<1;
            else cout<<0;
        }
        else cout<<-1;
        cout<<endl;
    }
    
	return 0;
}
0