結果
問題 | No.2709 1975 Powers |
ユーザー |
![]() |
提出日時 | 2024-07-27 14:13:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,000 bytes |
コンパイル時間 | 1,879 ms |
コンパイル使用メモリ | 169,268 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-07-27 14:13:33 |
合計ジャッジ時間 | 6,490 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 TLE * 1 -- * 23 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;#define rep(i,m,n) for(int i=m; i<n; ++i)#define repl(i,m,n) for(ll i=m; i<n; ++i)int powmod(int x, int n, int mod){int res = 1;while(n){if(n & 1) res = res * x % mod;x = x * x % mod;n >>= 1;}return res;}int main(){int N, P, Q;cin >> N >> P >> Q;vector<int> A(N);rep(i, 0, N) cin >> A[i];int ans = 0;vector<int> base = {10, 9, 7, 5};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){vector<int> ex = {A[i], A[j], A[k], A[l]};int val = 0;rep(m, 0, 4){val += powmod(base[m], ex[m], P);val %= P;}if(val == Q) ans++;}}}}cout << ans << endl;return 0;}