結果

問題 No.1140 EXPotentiaLLL!
ユーザー akaneakane
提出日時 2020-07-31 23:41:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,314 ms / 2,000 ms
コード長 1,014 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 200,028 KB
実行使用メモリ 50,140 KB
最終ジャッジ日時 2023-09-21 03:15:30
合計ジャッジ時間 15,156 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,284 ms
49,888 KB
testcase_01 AC 1,311 ms
50,116 KB
testcase_02 AC 1,287 ms
49,784 KB
testcase_03 AC 996 ms
49,800 KB
testcase_04 AC 785 ms
49,944 KB
testcase_05 AC 1,175 ms
49,872 KB
testcase_06 AC 1,130 ms
49,888 KB
testcase_07 AC 1,314 ms
49,956 KB
testcase_08 AC 110 ms
49,892 KB
testcase_09 AC 117 ms
49,872 KB
testcase_10 AC 117 ms
49,872 KB
testcase_11 AC 120 ms
49,816 KB
testcase_12 AC 120 ms
50,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
using ll = long long;

ll mod;

int main(){
    int testcase; cin>> testcase;
    vector<ll> vp(6000000+1,0);
    // set<ll> prime;
    for(int i=2; i*i<=6000000; i++){
        ll x=i+i;
        if(vp[i]==1) continue;
        while(x<=6000000){
          // if(i==3) cerr<< x << " "<<endl;
            vp[x]=1;
            x += i;
        }
    }
    // mod = 70;
    // cerr << pow_kai(3,4) << endl;
    // for(int i=2; i<100; i++){
    //   if(vp[i]==0){
    //     cerr << i << " ";
    //   }
    // }

    while(testcase--){
        ll A,P; cin>>A>>P;
        mod = P;
        // Aが素数かどうか。
        bool pflg = false;
        if(vp[P]==0 && P>=2){
          pflg=true;
        }else{
          cout << -1 << endl;
          continue;
        }

        // Pが素数の時
        ll x = A % P;
        if(x>=1){
          cout<< 1 << endl;
        }else{
          cout << 0 << endl;
        }
    }
}
0