結果

問題 No.984 Inversion
ユーザー Strorkis
提出日時 2020-02-11 15:32:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 367 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 63,488 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-01 07:58:33
合計ジャッジ時間 4,281 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main() {
  int p, n; cin >> p >> n;
  int a = n, x = a, c = 0, xc = 0, ans = 0;
  for (int i = 2; i < p; i++) {
    a = (a + n) % p;
    if (a < x) {
      c += xc;
      ans = (ans + c) % 2;
      x = a;
      xc = 1;
    }
    else if (a == x) {
      ans = (ans + c) % 2;
      xc++;
    }
  }
  cout << ans << endl;
}
0