結果
| 問題 |
No.1409 Simple Math in yukicoder
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-02-26 22:54:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,722 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 95,772 KB |
| 最終ジャッジ日時 | 2025-01-19 06:27:37 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 |
| other | WA * 28 RE * 30 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
void validate(int v, int x, vector<int> a){
assert(a.size() == x);
int p = x*v+1;
vector<int> tmp(x, 1);
for(int i = 1; i <= x; i++){
for(int j = 0; j < x; j++) tmp[j] = (tmp[j]*a[j])%p;
int sum = accumulate(tmp.begin(), tmp.end(), 0);
if(i == x) assert(sum%p == x);
else assert(sum%p == 0);
}
}
ll pow(ll a, ll n, ll MOD) {
ll ans = 1;
ll tmp = a;
for (int i = 0; i <= 60; i++) {
ll m = (ll)1 << i;
if (m & n) {
ans *= tmp;
ans %= MOD;
}
tmp *= tmp;
tmp %= MOD;
}
return ans;
}
void solve(){
int v, x; cin >> v >> x;
int p = x*v+1;
int a = -1;
for(int i = 2; i < p; i++){
if(pow(i, v, p) != 1){
a = i;
break;
}
}
assert(a != -1);
vector<int> ans;
for(int i = 0; i < x; i++){
ans.push_back(pow(a, i*v, p));
}
sort(ans.begin(), ans.end());
// validate(v, x, ans);
for(int x : ans) cout << x << ' ';
cout << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int t; cin >> t;
while(t--) solve();
}
milanis48663220