結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-02 13:31:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 805 ms / 2,000 ms |
| コード長 | 910 bytes |
| コンパイル時間 | 4,459 ms |
| コンパイル使用メモリ | 251,600 KB |
| 最終ジャッジ日時 | 2025-02-20 19:38:37 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
コンパイルメッセージ
main.cpp:9:4: warning: built-in function ‘pow10’ declared as non-function [-Wbuiltin-declaration-mismatch]
9 | ll pow10[2020202], pow9[2020202], pow7[2020202], pow5[2020202], ans;
| ^~~~~
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
int N, P, Q, A[202];
ll pow10[2020202], pow9[2020202], pow7[2020202], pow5[2020202], ans;
int main() {
cin >> N >> P >> Q;
for (int i = 0; i < N; i++) cin >> A[i];
sort(A, A + N);
pow10[0] = pow9[0] = pow7[0] = pow5[0] = 1;
for (int i = 1; i <= 2000000; i++) {
pow10[i] = (pow10[i - 1] * 10) % P;
pow9[i] = (pow9[i - 1] * 9) % P;
pow7[i] = (pow7[i - 1] * 7) % P;
pow5[i] = (pow5[i - 1] * 5) % P;
}
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 a = A[i], b = A[j], c = A[k], d = A[l];
if ((pow10[a] + pow9[b] + pow7[c] + pow5[d]) % P == Q) ans++;
}
}
}
}
cout << ans << endl;
return 0;
}