結果

問題 No.1140 EXPotentiaLLL!
ユーザー ぷらぷら
提出日時 2020-07-31 21:45:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 872 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 166,492 KB
実行使用メモリ 42,324 KB
最終ジャッジ日時 2023-09-20 22:41:44
合計ジャッジ時間 15,999 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,312 ms
42,192 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 160 ms
42,168 KB
testcase_09 AC 138 ms
42,236 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 136 ms
42,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mod_pow(int x,int y,int MOD) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%MOD;
        }
        x = x*x%MOD;
        y/=2;
    }
    return res;
}
signed main() {
    vector<int>cnt(5000005,true);
    cnt[0] = cnt[1] = false;
    for(int i = 2; i <= 5000005; i++) {
        if(!cnt[i]) {
            continue;
        }
        for(int j = i*2; j <= 5000005; j+=i) {
            cnt[j] = false;
        }
    }
    int T;
    cin >> T;
    for(int i = 0; i < T; i++) {
        int A,P;
        cin >> A >> P;
        if(!cnt[P]) {
            cout << -1 << endl;
            continue;
        }
        cout << mod_pow(A,(1+P)*P/2,P) << endl;
    }
}
0