結果
問題 | No.2709 1975 Powers |
ユーザー |
|
提出日時 | 2025-03-26 23:34:40 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 696 ms / 2,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 3,929 ms |
コンパイル使用メモリ | 279,912 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-26 23:34:53 |
合計ジャッジ時間 | 11,936 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) #define all(a) (a).begin(),(a).end() ll modpow(ll a, ll n, ll m) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % m; a = a * a % m; n >>= 1; } return res; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; ll P, Q; cin >> N >> P >> Q; vector<ll> t(N); rep(i, 0, N) cin >> t[i]; sort(all(t)); vector<ll> A(N), B(N), C(N), D(N); rep(i, 0, N) { A[i] = modpow(10, t[i], P); B[i] = modpow(9, t[i], P); C[i] = modpow(7, t[i], P); D[i] = modpow(5, t[i], P); } ll ans = 0; rep(a, 0, N - 3) rep(b, a + 1, N - 2) rep(c, b + 1, N - 1) rep(d, c + 1, N) { if ((A[a] + B[b] + C[c] + D[d]) % P == Q) ++ans; } cout << ans << '\n'; }