結果

問題 No.2709 1975 Powers
ユーザー Nichi10pNichi10p
提出日時 2024-03-31 14:04:05
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 2,457 ms
コンパイル使用メモリ 210,696 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-30 18:53:45
合計ジャッジ時間 4,321 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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