結果

問題 No.2709 1975 Powers
ユーザー Nichi10pNichi10p
提出日時 2024-03-31 14:04:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 2,353 ms
コンパイル使用メモリ 211,452 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:04:27
合計ジャッジ時間 4,232 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 53 ms
6,676 KB
testcase_04 AC 85 ms
6,676 KB
testcase_05 AC 58 ms
6,676 KB
testcase_06 AC 20 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 18 ms
6,676 KB
testcase_09 AC 58 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 4 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 61 ms
6,676 KB
testcase_14 AC 10 ms
6,676 KB
testcase_15 AC 11 ms
6,676 KB
testcase_16 AC 46 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 83 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 18 ms
6,676 KB
testcase_22 AC 100 ms
6,676 KB
testcase_23 AC 100 ms
6,676 KB
testcase_24 AC 118 ms
6,676 KB
testcase_25 AC 99 ms
6,676 KB
testcase_26 AC 99 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using Int = atcoder::modint;
ostream& operator<<(ostream &os, const Int &x) { return os << x.val(); }

int main() {
  int N, P, Q;
  cin >> N >> P >> Q;
  vector<int> A(N);
  for (int i=0; i < N; ++i)
    cin >> A[i];

  Int::set_mod(P);
  sort(A.begin(), A.end());
  auto R = vector(N, array<Int, 4>{});
  for (int i=0; i < N; ++i) {
    R[i][0] = Int(10).pow(A[i]);
    R[i][1] = Int(9).pow(A[i]);
    R[i][2] = Int(7).pow(A[i]);
    R[i][3] = Int(5).pow(A[i]);
  }

  long long cnt{};
  for (int ai=0;    ai < N; ++ai)
  for (int bi=ai+1; bi < N; ++bi)
  for (int ci=bi+1; ci < N; ++ci)
  for (int di=ci+1; di < N; ++di)
    cnt += R[ai][0] + R[bi][1] + R[ci][2] + R[di][3] == Q;

  cout << cnt << endl;
}
0