結果
| 問題 | No.2709 1975 Powers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-04-27 12:13:00 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 789 bytes | 
| コンパイル時間 | 1,919 ms | 
| コンパイル使用メモリ | 177,316 KB | 
| 実行使用メモリ | 17,096 KB | 
| 最終ジャッジ日時 | 2024-11-15 14:02:05 | 
| 合計ジャッジ時間 | 73,485 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 2 TLE * 23 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)j; i < (int)(n); i++)
using ll = long long int;
int main() {
  int N, P, Q;
  cin >> N >> P >> Q;
  vector<int> A(N);
  rep(i, 0, N)
    cin >> A[i];
  sort(A.begin(), A.end());
  vector<int> o = {10, 9, 7, 5};
  vector<vector<int>> a(N, vector<int> (4));
  rep(i, 0, N) {
    rep(j, 0, 4) {
      ll p = 1;
      rep(k, 0, A[i])
	p = (p * o[j]) % P;
      a[i][j] = p;
    }
  }
  int ans = 0;
  auto dfs = [&](auto dfs, int x, int n, int depth) {
    x = (x + a[n][depth]) % P;
    if (depth == 3) {
      if (x % P == Q)
	ans++;
      return;
    }
    rep(i, n+1, N) {
      dfs(dfs, x, i, depth+1);
    }
    return;
  };
  rep(i, 0, N)
    dfs(dfs, 0, i, 0);
  cout << ans << endl;
  return 0;
}
            
            
            
        