結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
Nichi10p
|
| 提出日時 | 2024-03-31 14:04:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 103 ms / 2,000 ms |
| コード長 | 781 bytes |
| コンパイル時間 | 2,285 ms |
| コンパイル使用メモリ | 203,496 KB |
| 最終ジャッジ日時 | 2025-02-20 16:52:45 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using Int = atcoder::modint;
ostream& operator<<(ostream &os, const Int &x) { return os << x.val(); }
int main() {
int N, P, Q;
cin >> N >> P >> Q;
vector<int> A(N);
for (int i=0; i < N; ++i)
cin >> A[i];
Int::set_mod(P);
sort(A.begin(), A.end());
auto R = vector(N, array<Int, 4>{});
for (int i=0; i < N; ++i) {
R[i][0] = Int(10).pow(A[i]);
R[i][1] = Int(9).pow(A[i]);
R[i][2] = Int(7).pow(A[i]);
R[i][3] = Int(5).pow(A[i]);
}
long long cnt{};
for (int ai=0; ai < N; ++ai)
for (int bi=ai+1; bi < N; ++bi)
for (int ci=bi+1; ci < N; ++ci)
for (int di=ci+1; di < N; ++di)
cnt += R[ai][0] + R[bi][1] + R[ci][2] + R[di][3] == Q;
cout << cnt << endl;
}
Nichi10p