結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー beetbeet
提出日時 2020-10-24 12:53:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,505 bytes
コンパイル時間 2,415 ms
コンパイル使用メモリ 212,844 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 20:23:22
合計ジャッジ時間 3,203 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 48 ms
4,376 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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!=0) continue;
      ps.emplace_back(i);
      res=res/i*(i-1);
      while(n%i==0) n/=i;
    }
    if(n!=1){
      ps.emplace_back(n);
      res=res/n*(n-1);
    }
    phi[MOD]=res;
  }

  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;
}
0