結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 13:41:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 790 ms / 2,000 ms |
| コード長 | 1,179 bytes |
| コンパイル時間 | 2,180 ms |
| コンパイル使用メモリ | 199,704 KB |
| 最終ジャッジ日時 | 2025-02-20 16:26:51 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T = ll>
using vc = vector<T>;
template <class T = ll>
using vvc = vc<vc<T>>;
void solve();
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
ll t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) solve();
return 0;
}
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
ll dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0};
void solve() {
ll n, p, q;
cin >> n >> p >> q;
vc<ll> a(n);
rep(i, 0, n) cin >> a[i];
sort(a.begin(), a.end());
const ll N = 2e6;
vc<ll> pow10(N + 1), pow9(N + 1), pow7(N + 1), pow5(N + 1);
pow10[0] = 1, pow9[0] = 1, pow7[0] = 1, pow5[0] = 1;
rep(i, 1, N + 1) {
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;
}
ll res = 0;
rep(i, 0, n) rep(j, i + 1, n) rep(k, j + 1, n) rep(l, k + 1, n) {
ll num = pow10[a[i]] + pow9[a[j]] + pow7[a[k]] + pow5[a[l]];
if (num % p == q) res++;
}
cout << res << endl;
}