結果
問題 | No.1287 えぬけー |
ユーザー |
![]() |
提出日時 | 2020-11-13 22:14:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 283 ms / 2,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 2,222 ms |
コンパイル使用メモリ | 198,524 KB |
最終ジャッジ日時 | 2025-01-15 23:20:04 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/math> using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000005 #define modulo 1000000007 int main(){ int T; cin>>T; rep(_,T){ int X,K; cin>>X>>K; vector<long long> num(30); num[0] = X; for(int i=1;i<30;i++){ num[i] = num[i-1]; num[i] *= num[i-1]; num[i] %= modulo; } long long x = inv_mod(K,modulo-1); long long ans = 1; rep(i,30){ if((x>>i)&1)ans *= num[i]; ans %= modulo; } cout<<ans<<endl; } return 0; }