結果

問題 No.1409 Simple Math in yukicoder
ユーザー m_tsubasa
提出日時 2021-02-26 23:17:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 1,841 ms
コンパイル使用メモリ 192,728 KB
最終ジャッジ日時 2025-01-19 07:04:30
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 TLE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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;

int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> v >> x;
    int cnt = 0;
    int pr = v * x + 1;
    for (int i = 1; cnt < x; ++i)
      if (modpow(i, x, pr) == 1) cout << i << " \n"[++cnt == x];
  }
  return 0;
}
0