結果
問題 | No.1409 Simple Math in yukicoder |
ユーザー | trineutron |
提出日時 | 2021-02-26 22:46:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 1,258 bytes |
コンパイル時間 | 2,081 ms |
コンパイル使用メモリ | 200,744 KB |
最終ジャッジ日時 | 2025-01-19 06:22:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using namespace atcoder; void solve() { int v, x; cin >> v >> x; if (x == 1) { cout << 1 << endl; return; } modint::set_mod(x * v + 1); for (int i = 2; i <= x * v; i++) { modint k = modint(i).pow(v); bool good = true; for (int j = 1; j < x; j++) { if (k.pow(j).val() == 1) { good = false; break; } } if (good) { vector<int> ans; ans.push_back(1); for (int j = 1; j < x; j++) { ans.push_back((ans.back() * k).val()); } sort(ans.begin(), ans.end()); for (int j = 0; j < x; j++) { cout << ans.at(j); if (j == x - 1) { cout << endl; } else { cout << " "; } } break; } } } int main(int argc, char const *argv[]) { int t; cin >> t; for (int i = 0; i < t; i++) { solve(); } return 0; }