結果
問題 | No.2709 1975 Powers |
ユーザー |
![]() |
提出日時 | 2024-03-31 14:39:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,604 bytes |
コンパイル時間 | 2,364 ms |
コンパイル使用メモリ | 205,516 KB |
最終ジャッジ日時 | 2025-02-20 17:20:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 TLE * 1 -- * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;vector<long long> v = {10LL, 9LL, 7LL, 5LL};int siz = 2000010;long long modpow(long long a, long long b, long long mod) {long long cur = a, ans = 1;for (int i = 0; i < 60; i++) {if (b & (1LL << i)) {ans = (ans * cur) % mod;}cur = (cur * cur) % mod;}return ans;}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;}}vector<char> c;for (int i = 0; i < 4; i++) {c.push_back('o');}for (int i = 0; i < n - 4; i++) {c.push_back('x');}sort(a.begin(), a.end());int ans = 0;do {long long res = 0LL;int w = -1, x = -1, y = -1, z = -1;for (int i = 0; i < n; i++) {if (c[i] == 'o') {if (w == -1) {w = i;} else if (x == -1) {x = i;} else if (y == -1) {y = i;} else {z = i;}}}res += (((mods[0][a[w]] + mods[1][a[x]]) % p + mods[2][a[y]]) % p + mods[3][a[z]]) % p;if (res == q) {ans++;}} while (next_permutation(c.begin(), c.end()));cout << ans << endl;}