結果
| 問題 | No.1255 ハイレーツ・オブ・ボリビアン |
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-10-09 22:31:51 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,824 bytes |
| 記録 | |
| コンパイル時間 | 1,444 ms |
| コンパイル使用メモリ | 207,872 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-14 09:48:40 |
| 合計ジャッジ時間 | 2,354 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const char newl = '\n';
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
vector<T> ts(n);
for(size_t i=0;i<n;i++) cin>>ts[i];
return ts;
}
vector<Int> identity(Int n){
vector<Int> ord(n);
iota(ord.begin(),ord.end(),0);
return ord;
}
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;
}
template<typename T>
T order(T x,T MOD){
T res=MOD-1;
vector<T> cand;
for(T i=1;i*i<=res;i++){
if(res%i) continue;
cand.emplace_back(i);
cand.emplace_back(res/i);
}
sort(cand.begin(),cand.end());
for(T c:cand)
if(mod_pow(x,c,MOD)==1) return c;
return res;
}
//INSERT ABOVE HERE
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
auto solve=[](Int n){
return order<Int>(2,2*n-1);
/*
Int res=0,tmp=1;
do{
tmp+=2*n-1;
while(tmp%2==0) tmp/=2,res++;
}while(tmp!=1);
return res;
*/
};
auto naive=[&](Int n){
vector<Int> as=identity(2*n);
Int cnt=0;
do{
cnt++;
vector<Int> bs(as);
for(Int i=0;i<n;i++){
as[i*2+0]=bs[0+i];
as[i*2+1]=bs[n+i];
}
}while(as!=identity(2*n));
return cnt;
};
const Int EXPERIMENT = 0;
if(EXPERIMENT){
for(Int n=1;n<=30;n++){
cout<<n<<':'<<naive(n)<<':'<<solve(n)<<newl;
assert(naive(n)==solve(n));
}
}
Int T;
cin>>T;
while(T--){
Int n;
cin>>n;
cout<<solve(n)<<newl;
}
return 0;
}
beet