結果

問題 No.1409 Simple Math in yukicoder
ユーザー m_tsubasa
提出日時 2021-02-26 22:38:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,383 bytes
コンパイル時間 3,601 ms
コンパイル使用メモリ 203,480 KB
最終ジャッジ日時 2025-01-19 06:05:51
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 TLE * 53
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
map<int, int> fact(int p) {
map<int, int> res;
for (int i = 2; i * i <= p; ++i)
while (p % i == 0) ++res[i], p /= i;
if (p > 1) ++res[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, map<int, int>& mp) {
int res = x * v, pr = x * v + 1;
for (auto [x, y] : mp) {
while (res % x == 0 && modpow(p, res / x, pr) == 1) res /= x;
}
return res;
}
void dfs(int now = 0, int par = 0);
int main() {
int t;
cin >> t;
while (t--) {
cin >> v >> x;
auto mp = fact(x * v);
vector<int> res;
for (int i = 1; i <= x * v; ++i)
if (x % calc(i, mp) == 0) 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);
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0