結果

問題 No.2709 1975 Powers
ユーザー a01sa01toa01sa01to
提出日時 2024-03-31 13:45:21
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 1,000 bytes
コンパイル時間 3,176 ms
コンパイル使用メモリ 257,068 KB
実行使用メモリ 75,264 KB
最終ジャッジ日時 2024-03-31 13:45:39
合計ジャッジ時間 11,171 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 33 ms
24,704 KB
testcase_03 AC 327 ms
38,912 KB
testcase_04 AC 586 ms
63,872 KB
testcase_05 AC 395 ms
51,200 KB
testcase_06 AC 155 ms
18,304 KB
testcase_07 AC 9 ms
9,984 KB
testcase_08 AC 184 ms
48,256 KB
testcase_09 AC 418 ms
56,192 KB
testcase_10 AC 9 ms
10,368 KB
testcase_11 AC 33 ms
13,440 KB
testcase_12 AC 84 ms
39,424 KB
testcase_13 AC 443 ms
68,096 KB
testcase_14 AC 102 ms
22,912 KB
testcase_15 AC 136 ms
46,336 KB
testcase_16 AC 329 ms
30,592 KB
testcase_17 AC 12 ms
11,136 KB
testcase_18 AC 100 ms
40,960 KB
testcase_19 AC 536 ms
57,344 KB
testcase_20 AC 29 ms
23,040 KB
testcase_21 AC 184 ms
47,872 KB
testcase_22 AC 583 ms
75,264 KB
testcase_23 AC 634 ms
60,672 KB
testcase_24 AC 605 ms
36,480 KB
testcase_25 AC 640 ms
58,240 KB
testcase_26 AC 654 ms
64,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

#include <atcoder/modint>
using mint = atcoder::dynamic_modint<1>;

int main() {
  int n, p, q;
  cin >> n >> p >> q;
  mint::set_mod(p);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  vector cnt(n + 1, vector<int>(p, 0));
  for (int i = n - 1; i >= 0; i--) {
    mint x = mint(5).pow(a[i]);
    for (int j = 0; j < p; j++) {
      cnt[i][j] = cnt[i + 1][j];
      if (x.val() == j) cnt[i][j]++;
    }
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        mint rem = mint(q) - mint(10).pow(a[i]) - mint(9).pow(a[j]) - mint(7).pow(a[k]);
        ans += cnt[k + 1][rem.val()];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
0