結果
問題 |
No.1255 ハイレーツ・オブ・ボリビアン
|
ユーザー |
![]() |
提出日時 | 2020-10-24 12:57:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 1,568 bytes |
コンパイル時間 | 2,063 ms |
コンパイル使用メモリ | 207,264 KB |
最終ジャッジ日時 | 2025-01-15 15:00:08 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 15 |
ソースコード
// verification-helper: PROBLEM https://yukicoder.me/problems/4474 #include<bits/stdc++.h> using namespace std; #define call_from_test #ifndef call_from_test #include<bits/stdc++.h> using namespace std; #endif //BEGIN CUT HERE template<typename T> T mod_pow(T a,long long n,T mod){ using ll = long long; T res(1); while(n){ if(n&1) res=(ll)res*a%mod; a=(ll)a*a%mod; n>>=1; } return res; } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #ifndef call_from_test #include <bits/stdc++.h> using namespace std; #define call_from_test #include "pow.cpp" #undef call_from_test #endif //BEGIN CUT HERE template<typename T> T order(T x,T MOD){ static map<T, vector<T>> dp; static map<T, T> phi; vector<T> &ps=dp[MOD]; if(ps.empty()){ T res=MOD,n=MOD; for(T i=2;i*i<=n;i++){ if(n%i) continue; res=res/i*(i-1); while(n%i==0) n/=i; } if(n!=1) res=res/n*(n-1); phi[MOD]=res; for(T i=2;i*i<=res;i++){ if(res%i) continue; ps.emplace_back(i); if(i*i!=res) ps.emplace_back(res/i); } } T res=phi[MOD]; for(T p:ps){ while(res%p==0){ if(mod_pow(x,res/p,MOD)!=1) break; res/=p; } } return res; } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); const char newl = '\n'; int T; cin>>T; while(T--){ long long n; cin>>n; cout<<order(2LL,2*n-1)<<newl; } return 0; }