結果

問題 No.2709 1975 Powers
ユーザー hatsuka_iwahatsuka_iwa
提出日時 2024-03-31 15:29:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 210,332 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 15:29:46
合計ジャッジ時間 7,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 5 ms
6,548 KB
testcase_03 AC 221 ms
6,548 KB
testcase_04 AC 371 ms
6,548 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,548 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,548 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 38 ms
6,548 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 434 ms
6,548 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 430 ms
6,548 KB
testcase_26 AC 433 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int N, P, Q, C = 0; cin >> N >> P >> Q;
  vector<int> A(N);
  vector B(4, vector<int>(N));

  auto pow = [&](long long x, long long n) {
    long long ret = 1;
    while (n) {
      if (n & 1) ret = ret * x % P;
      x = x * x % P;
      n = n >> 1;
    }
    return ret;
  };

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(0).at(i) = pow(10, A.at(i));
    B.at(1).at(i) = pow(9, A.at(i));
    B.at(2).at(i) = pow(7, A.at(i));
    B.at(3).at(i) = pow(5, A.at(i));
  }

  sort(A.begin(), A.end());
  for (int i = 0; i < N - 3; i++)
    for (int j = i + 1; j < N - 2; j++)
      for (int k = j + 1; k < N - 1; k++)
        for (int l = k + 1; l < N; l++)
          if ((B.at(0).at(i) + B.at(1).at(j) + B.at(2).at(k) + B.at(3).at(l)) % P == Q) C++;

  cout << C << endl;
}
0