結果
問題 | No.2709 1975 Powers |
ユーザー | akinyan |
提出日時 | 2024-03-31 13:53:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 700 ms / 2,000 ms |
コード長 | 1,526 bytes |
コンパイル時間 | 3,274 ms |
コンパイル使用メモリ | 261,580 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-30 18:33:38 |
合計ジャッジ時間 | 10,741 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#ifndef akinyan #define akinyan #include <bits/stdc++.h> using namespace std; using ch = char; using ll = long long; using ld = long double; using db = double; using st = string; using vdb = vector<db>; using vvdb = vector<vdb>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vd = vector<ld>; using vvd = vector<vd>; using vs = vector<st>; using vvs = vector<vs>; using vc = vector<ch>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; const ll mod = 998244353; const ll MOD = 1000000007; const ll INF = 1000000000000000000LL; using pall = pair<ll,ll>; using vp = vector<pall>; #endif 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(){ ll N,P,Q; cin>>N>>P>>Q; vl A(N); for(int i=0; i<N; i++){ cin>>A[i]; } ranges::sort(A); vvl X(N,vl(4)); for(int i=0; i<N; i++){ X[i][0] = modpow(10,A[i],P); X[i][1] = modpow(9,A[i],P); X[i][2] = modpow(7,A[i],P); X[i][3] = modpow(5,A[i],P); } ll ans = 0; for(int a=0; a<N; a++){ for(int b=a+1; b<N; b++){ for(int c=b+1; c<N; c++){ for(int d=c+1; d<N; d++){ if((X[a][0] + X[b][1] + X[c][2] + X[d][3]) % P == Q){ ans++; } } } } } cout << ans << endl; }