結果

問題 No.2709 1975 Powers
ユーザー 👑 Nafmo2Nafmo2
提出日時 2024-01-25 01:52:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 4,294 ms
コンパイル使用メモリ 267,768 KB
実行使用メモリ 34,744 KB
最終ジャッジ日時 2024-01-25 02:08:13
合計ジャッジ時間 9,749 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 132 ms
34,232 KB
testcase_03 AC 183 ms
34,360 KB
testcase_04 AC 226 ms
34,232 KB
testcase_05 AC 196 ms
34,616 KB
testcase_06 AC 152 ms
34,616 KB
testcase_07 AC 130 ms
34,104 KB
testcase_08 AC 149 ms
34,616 KB
testcase_09 AC 191 ms
34,488 KB
testcase_10 AC 133 ms
34,744 KB
testcase_11 AC 129 ms
33,464 KB
testcase_12 AC 137 ms
34,744 KB
testcase_13 AC 197 ms
34,616 KB
testcase_14 AC 139 ms
34,232 KB
testcase_15 AC 140 ms
34,104 KB
testcase_16 AC 184 ms
34,744 KB
testcase_17 AC 133 ms
34,616 KB
testcase_18 AC 139 ms
34,616 KB
testcase_19 AC 226 ms
34,616 KB
testcase_20 AC 127 ms
33,336 KB
testcase_21 AC 147 ms
34,104 KB
testcase_22 AC 232 ms
34,744 KB
testcase_23 AC 230 ms
34,744 KB
testcase_24 AC 228 ms
34,744 KB
testcase_25 AC 229 ms
34,744 KB
testcase_26 AC 229 ms
34,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0