結果

問題 No.1409 Simple Math in yukicoder
ユーザー sapphire__15sapphire__15
提出日時 2021-02-27 11:26:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 2,330 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 124,820 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 15:34:11
合計ジャッジ時間 35,066 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 23 ms
6,940 KB
testcase_08 AC 76 ms
6,940 KB
testcase_09 AC 17 ms
6,944 KB
testcase_10 AC 61 ms
6,944 KB
testcase_11 AC 79 ms
6,940 KB
testcase_12 AC 64 ms
6,944 KB
testcase_13 AC 25 ms
6,940 KB
testcase_14 AC 22 ms
6,940 KB
testcase_15 AC 28 ms
6,944 KB
testcase_16 AC 27 ms
6,944 KB
testcase_17 AC 101 ms
6,940 KB
testcase_18 AC 48 ms
6,940 KB
testcase_19 AC 57 ms
6,944 KB
testcase_20 AC 42 ms
6,944 KB
testcase_21 AC 39 ms
6,944 KB
testcase_22 AC 64 ms
6,940 KB
testcase_23 AC 14 ms
6,940 KB
testcase_24 AC 14 ms
6,944 KB
testcase_25 AC 57 ms
6,940 KB
testcase_26 AC 67 ms
6,940 KB
testcase_27 AC 117 ms
6,944 KB
testcase_28 AC 113 ms
6,940 KB
testcase_29 AC 117 ms
6,940 KB
testcase_30 AC 112 ms
6,944 KB
testcase_31 AC 110 ms
6,944 KB
testcase_32 AC 110 ms
6,940 KB
testcase_33 AC 109 ms
6,940 KB
testcase_34 AC 105 ms
6,940 KB
testcase_35 AC 106 ms
6,940 KB
testcase_36 AC 117 ms
6,940 KB
testcase_37 AC 280 ms
6,944 KB
testcase_38 AC 285 ms
6,940 KB
testcase_39 AC 292 ms
6,940 KB
testcase_40 AC 311 ms
6,940 KB
testcase_41 AC 303 ms
6,944 KB
testcase_42 AC 300 ms
6,940 KB
testcase_43 AC 290 ms
6,944 KB
testcase_44 AC 301 ms
6,940 KB
testcase_45 AC 302 ms
6,944 KB
testcase_46 AC 318 ms
6,940 KB
testcase_47 AC 291 ms
6,940 KB
testcase_48 AC 304 ms
6,944 KB
testcase_49 AC 300 ms
6,940 KB
testcase_50 AC 310 ms
6,940 KB
testcase_51 AC 297 ms
6,940 KB
testcase_52 AC 303 ms
6,940 KB
testcase_53 AC 306 ms
6,944 KB
testcase_54 AC 299 ms
6,940 KB
testcase_55 AC 322 ms
6,944 KB
testcase_56 AC 312 ms
6,940 KB
testcase_57 AC 325 ms
6,948 KB
testcase_58 AC 323 ms
6,944 KB
testcase_59 AC 346 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>
#include <iomanip>
#include <limits>

typedef int64_t ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename _T>
using MaxHeap = std::priority_queue<_T>;
template<typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;

template<typename _T>
inline bool chmax(_T &_l, const _T _b) {
    if (_l < _b) {
        _l = _b;
        return true;
    }
    return false;
}
template<typename _T>
inline bool chmin(_T &_l, const _T _b) {
    if (_l > _b) {
        _l = _b;
        return true;
    }
    return false;
}

// # ifdef LOCAL_DEBUG
template<typename _T>
void vdeb(const std::vector<_T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}
// # endif

using namespace std;

long long modpow(long long _n, long long _k, long long _p) {
    long long _ret = 1, _now = _n;
    while(_k) {
        if(_k&1) _ret = _ret * _now % _p;
        _now = _now * _now % _p;
        _k >>= 1;
    }
    return _ret;
}

void solve() {
    int v, x; cin >> v >> x;
    int p = v*x + 1, an = 1;
    rip(i,p,1) {
        if(modpow(i, x, p) != 1) continue;
        int now = 1;
        bool flg = true;
        rip(j,x-1,0) {
            now = now*i%p;
            if(now%p == 1) {
                flg = false;
                break;
            }
        }
        if(flg) {
            an = i;
            break;
        }
    }
    vector<int> ans(x);
    ans[0] = 1;
    rip(i,x,1) ans[i] = ans[i-1]*an%p;
    sort(all(ans));
    vdeb(ans);
}

int main() {
    int t; cin >> t;
    rip(i,t,0) solve();
}
0