結果
| 問題 | No.2709 1975 Powers |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-04 03:03:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 983 bytes |
| 記録 | |
| コンパイル時間 | 4,992 ms |
| コンパイル使用メモリ | 310,884 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-04 03:04:04 |
| 合計ジャッジ時間 | 8,725 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 TLE * 1 -- * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#ifdef LOCAL
#include <algo/debug.h>
#else
#define debug(...) void(0)
#endif
#include<atcoder/all>
using namespace atcoder;
ll modpow(ll a, ll b, ll m) {
ll ret = 1;
while(b) {
if(b & 1) (ret *= a) % m;
(a *= a) % m;
b >>= 1;
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N, P, Q; cin >> N >> P >> Q;
vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
sort(A.begin(), A.end());
ll ans = 0;
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++) {
ll t = modpow(10, A[i], P) + modpow(9, A[j], P) + modpow(7, A[k], P) + modpow(5, A[l], P); t %= P;
if(t == Q) ans++;
}
}
}
}
cout << ans << endl;
}