結果

問題 No.1409 Simple Math in yukicoder
ユーザー m_tsubasam_tsubasa
提出日時 2021-02-26 23:00:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,586 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 201,532 KB
実行使用メモリ 13,764 KB
最終ジャッジ日時 2024-04-10 13:43:05
合計ジャッジ時間 6,113 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,764 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 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 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<int> fact(int p) {
  vector<int> res;
  for (int i = 2; i * i <= p; ++i) {
    res.push_back(i);
    while (p % i == 0) p /= i;
  }
  if (p > 1) res.push_back(p);
  return res;
}

long long modpow(long long b, long long x, long long mod) {
  long long res = 1;
  while (x) {
    if (x & 1) (res *= b) %= mod;
    (b *= b) %= mod;
    x >>= 1;
  }
  return res;
}

int x, v;
vector<int> res;

int calc(int p, vector<int>& vec) {
  int res = x * v, pr = x * v + 1;
  for (auto x : vec) {
    while (res % x == 0 && modpow(p, res / x, pr) == 1) res /= x;
  }
  return res;
}

vector<vector<int>> memo;
void dfs(int now = 0, int par = 0);

int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> v >> x;
    vector<int> res;
    int pr = v * x + 1;
    for (int i = 1; i <= x * v; ++i) {
      long long p = 1;
      bool ch = 0;
      for (int j = 0; j < x; ++j)
        if (((p *= i) %= pr) == 1) {
          ch = x % (j + 1) == 0;
          break;
        }
      if (ch) res.push_back(i);
    }
    for (int i = 0; i < x; ++i) cout << res[i] << " \n"[i == x - 1];
  }
  return 0;
}

void dfs(int now, int par) {
  if (now == x) {
    vector<long long> vec(x, 1);
    for (int i = 0; i < x; ++i) {
      long long sum = 0;
      for (int j = 0; j < x; ++j) sum += (vec[j] *= res[j]);
      if (sum % (v * x + 1) != (i == x - 1 ? x : 0)) return;
    }
    for (auto p : res) cout << p << " ";
    cout << endl;
    return;
  }
  int xv = x * v;
  for (int i = par + 1; i <= xv; ++i) {
    res[now] = i;
    dfs(now + 1, i);
  }
}
0