結果
問題 | No.2709 1975 Powers |
ユーザー |
![]() |
提出日時 | 2024-12-30 18:55:22 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,751 bytes |
コンパイル時間 | 3,800 ms |
コンパイル使用メモリ | 245,876 KB |
実行使用メモリ | 34,688 KB |
最終ジャッジ日時 | 2024-12-30 18:55:34 |
合計ジャッジ時間 | 11,204 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 16 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;#define rep(i,m,n) for(int i=m; i<int(n); ++i)#define repll(i,m,n) for(ll i=m; i<ll(n); ++i)#define all(a) (a).begin(), (a).end()#define rall(a) (a).rbegin(), (a).rend()#define fi first#define se secondtemplate<typename T> bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; }template<typename T> bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; }template<typename T> T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; }template<typename T> T lcm(T a, T b){ return a / gcd(a, b) * b; }const int MAX = 2000100;int pow10[MAX], pow9[MAX], pow7[MAX], pow5[MAX];void init(int P){pow10[0] = 1;for(int i = 1; i < MAX; ++i){pow10[i] = pow10[i-1] * 10;pow10[i] %= P;}pow9[0] = 1;for(int i = 1; i < MAX; ++i){pow9[i] = pow9[i-1] * 9;pow9[i] %= P;}pow5[0] = 1;for(int i = 1; i < MAX; ++i){pow5[i] = pow5[i-1] * 5;pow5[i] %= P;}pow7[0] = 1;for(int i = 1; i < MAX; ++i){pow7[i] = pow7[i-1] * 7;pow7[i] %= P;}return;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int N, P, Q;cin >> N >> P >> Q;vector<int> A(N);rep(i, 0, N) cin >> A[i];init(P);int 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){int sum = (((((pow10[A[i]] + pow9[A[j]]) % P) + pow7[A[k]]) % P) + pow5[A[l]]) % P;if(sum == Q) ++ans;}}}}cout << ans << endl;return 0;}