結果
| 問題 | No.2709 1975 Powers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-04-01 02:18:18 | 
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,085 bytes | 
| コンパイル時間 | 21,764 ms | 
| コンパイル使用メモリ | 355,312 KB | 
| 最終ジャッジ日時 | 2025-02-20 18:39:46 | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 9 WA * 16 | 
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using P=pair<ll,ll>;
void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  IO();
  ll n,p,q;
  cin>>n>>p>>q;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  vector<vector<ll>> info(4,vector<ll>(n));
  for(ll i=0;i<n;i++){
    info[0][i]=modpow(10,a[i],p);
    info[1][i]=modpow(9,a[i],p);
    info[2][i]=modpow(7,a[i],p);
    info[3][i]=modpow(5,a[i],p);
  }
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      for(ll k=j+1;k<n;k++){
        for(ll l=k+1;l<n;l++){
          if((info[0][i]+info[1][j]+info[2][k]+info[3][l])%p==q){
            ans++;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}
            
            
            
        