結果
問題 | No.2709 1975 Powers |
ユーザー |
|
提出日時 | 2024-04-09 15:32:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 657 ms / 2,000 ms |
コード長 | 1,090 bytes |
コンパイル時間 | 1,872 ms |
コンパイル使用メモリ | 200,544 KB |
最終ジャッジ日時 | 2025-02-20 23:22:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for(int i=0; i<n; i++)#define debug 0#define YES cout << "Yes" << endl;#define NO cout << "No" << endl;using ll = long long;using ld = long double;const int mod = 998244353;const int MOD = 1000000007;const double pi = atan2(0, -1);#include <time.h>#include <chrono>ll modpow(ll x, int y, int m) {if (y == 0) {return 1;}if (y % 2 == 0) {ll t = modpow(x, y / 2, m);return (t * t) % m;}else {return (modpow(x, y - 1, m) * x) % m;}}int main() {int N, P, Q;cin >> N >> P >> Q;vector<int> A(N);rep(i, N) {cin >> A[i];}sort(A.begin(), A.end());vector<ll> mi(N), mj(N), mk(N), ml(N);rep(i, N) {mi[i] = modpow(10, A[i], P);mj[i] = modpow(9, A[i], P);mk[i] = modpow(7, A[i], P);ml[i] = modpow(5, A[i], P);}int ans = 0;rep(i, N) {for (int j = i + 1; j < N; j++) {for (int k = j + 1; k < N; k++) {for (int l = k + 1; l < N; l++) {if ((mi[i] + mj[j] + mk[k] + ml[l]) % P == Q) {ans++;}}}}}cout << ans << endl;}