結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー shinchanshinchan
提出日時 2022-12-26 11:59:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,366 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 208,076 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-30 22:22:39
合計ジャッジ時間 3,703 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
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 AC 67 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 96 ms
6,944 KB
testcase_15 AC 64 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


long long modpow(long long a, long long n, ll mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


ll phi(ll n) {
    ll m = n;
    ll ans = 1;
    for(ll i = 2; i * i <= n; i ++) {
        if(m % i == 0) {
            m /= i;
            ans *= (i - 1);
        } else continue;
        while(m % i == 0) {
            m /= i;
            ans *= i;
        }
    }
    if(m > 1) ans *= m - 1;
    return ans;
}

vector<ll> divisor(ll n) {
    vector<ll> v;
    for(ll i = 1; i * i <= n ; i ++) {
        if(n % i == 0) {
            if(i * i != n) v.pb(n / i);
            else v.pb(i);
        }
    }
    return v;
}
void solve() {
    ll n;
    cin >> n;

    auto v = divisor(phi(n * 2 - 1));
    sort(be(v));
    all(e, v) {
        if(modpow(2LL, e, n * 2 - 1) == 1) {
            cout << e << endl;
            return ;
        } 
    }
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false); 
    int t;
    cin >> t;
    while(t--) solve();
    return 0; 
}
0