結果

問題 No.1125 Without Parallelogram
ユーザー SSRS
提出日時 2020-07-22 23:39:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 173,868 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 01:40:47
合計ジャッジ時間 6,593 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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