結果
| 問題 | No.2709 1975 Powers |
| コンテスト | |
| ユーザー |
Tatsu_mr
|
| 提出日時 | 2024-03-31 15:42:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 998 bytes |
| 記録 | |
| コンパイル時間 | 2,172 ms |
| コンパイル使用メモリ | 204,172 KB |
| 最終ジャッジ日時 | 2025-02-20 17:59:09 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 TLE * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<long long> v = {10LL, 9LL, 7LL, 5LL};
int siz = 2000010;
int main() {
int n;
long long p, q;
cin >> n >> p >> q;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<vector<long long>> mods(4, vector<long long>(siz, 1LL));
for (int i = 0; i < 4; i++) {
for (int j = 1; j < siz; j++) {
mods[i][j] = mods[i][j - 1] * v[i] % p;
}
}
sort(a.begin(), a.end());
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++) {
if (i < j && j < k && k < l) {
if ((mods[0][a[i]] + mods[1][a[j]] + mods[2][a[k]] + mods[3][a[l]]) % p == q) {
ans++;
}
}
}
}
}
}
cout << ans << endl;
}
Tatsu_mr