結果

問題 No.1287 えぬけー
ユーザー chocoruskchocorusk
提出日時 2020-11-13 21:34:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 125,460 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 02:37:14
合計ジャッジ時間 3,137 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 248 ms
4,380 KB
testcase_06 AC 250 ms
4,376 KB
testcase_07 AC 257 ms
4,380 KB
testcase_08 AC 237 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
using ll=long long;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a, ll m){
    ll b=m, x=1, y=0;
    while(b>0){
        ll t=a/b;
        swap(a-=t*b, b);
        swap(x-=t*y, y);
    }
    return (x%m+m)%m;
}
int main()
{
    int t; cin>>t;
    while(t--){
        ll x, k; cin>>x>>k;
        ll a=inv(k, MOD-1);
        cout<<powmod(x, a)<<endl;
    }
    return 0;
}
0