結果

問題 No.1140 EXPotentiaLLL!
ユーザー ytftytft
提出日時 2021-05-07 18:57:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,234 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 4,500 ms
コンパイル使用メモリ 369,620 KB
実行使用メモリ 22,852 KB
最終ジャッジ日時 2023-10-13 10:05:15
合計ジャッジ時間 16,813 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,203 ms
22,544 KB
testcase_01 AC 1,206 ms
22,556 KB
testcase_02 AC 1,213 ms
22,852 KB
testcase_03 AC 915 ms
22,568 KB
testcase_04 AC 697 ms
22,556 KB
testcase_05 AC 1,106 ms
22,504 KB
testcase_06 AC 1,065 ms
22,676 KB
testcase_07 AC 1,234 ms
22,472 KB
testcase_08 AC 113 ms
22,520 KB
testcase_09 AC 111 ms
22,612 KB
testcase_10 AC 137 ms
22,488 KB
testcase_11 AC 76 ms
22,440 KB
testcase_12 AC 67 ms
22,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;

int main(){
    int N;
    cin>>N;
    long long A,P;
    vector<int> M(5000001,1);
    M[1]=0;
    for(int i=2;i<5000001;i++){
        if(M[i]){
            for(int j=i*2;j<5000001;j+=i){
                M[j]=0;
            }
        }
    }
    for(int i=0;i<N;i++){
        cin>>A>>P;
        cout<<(M[P]*(1+(A%P!=0))-1)<<endl;
    }
    
}
0