結果

問題 No.1125 Without Parallelogram
ユーザー SSRSSSRS
提出日時 2020-07-22 23:46:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 646 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 172,416 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 05:27:25
合計ジャッジ時間 6,141 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 5 ms
4,384 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 7 ms
4,376 KB
testcase_24 AC 12 ms
4,376 KB
testcase_25 AC 9 ms
4,380 KB
testcase_26 AC 8 ms
4,376 KB
testcase_27 AC 8 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:34:23: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
   34 |     a.push_back((a[i] * x) % p);
      |                 ~~~~~~^~~~
main.cpp:21:7: 備考: ‘x’ はここで定義されています
   21 |   int x;
      |       ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
bool ok(int n, int x){
  int a = 1;
  set<int> st;
  st.insert(a);
  for (int i = 0; i < n - 1; i++){
    a *= x;
    a %= n;
    if (a == 0){
      return false;
    }
    st.insert(a);
  }
  return st.size() == n - 1;
}
int main(){
  int N;
  cin >> N;
  int p;
  int x;
  for (int i = 2; i <= 10; i++){
    p = max(N, i + 1);
    while (!ok(p, i)){
      p++;
    }
    if (p < N + 42){
      x = i;
      break;
    }
  }
  vector<int> a = {1};
  for (int i = 0; i < N - 1 ; i++){
    a.push_back((a[i] * x) % p);
  }
  for (int i = 0; i < N; i++){
    cout << i << ' ' << a[i] - 1 << endl;
  }
}
0