結果
| 問題 | No.2709 1975 Powers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-01-25 01:52:47 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 248 ms / 2,000 ms | 
| コード長 | 924 bytes | 
| コンパイル時間 | 4,471 ms | 
| コンパイル使用メモリ | 254,896 KB | 
| 最終ジャッジ日時 | 2025-02-18 22:37:13 | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 25 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main() {
  int ans = 0;
  int N, P, Q;
  cin >> N >> P >> Q;
  modint::set_mod(P);
  vector<int> A(N, 0);
  int Amax = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  Amax = A[N - 1];
  vector<modint> p10, p9, p7, p5;
  p10.push_back(1);
  p9.push_back(1);
  p7.push_back(1);
  p5.push_back(1);
  for (int i = 0; i < Amax; i++) {
    p10.push_back(p10[i] * 10);
    p9.push_back(p9[i] * 9);
    p7.push_back(p7[i] * 7);
    p5.push_back(p5[i] * 5);
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        for (int l = k + 1; l < N; l++) {
          int res = (p10[A[i]] + p9[A[j]] + p7[A[k]] + p5[A[l]]).val();
          if (res == Q) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
            
            
            
        