結果

問題 No.2709 1975 Powers
ユーザー twooimp2twooimp2
提出日時 2024-04-01 02:18:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,085 bytes
コンパイル時間 6,837 ms
コンパイル使用メモリ 303,268 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-01 02:18:34
合計ジャッジ時間 15,036 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 7 ms
6,676 KB
testcase_03 AC 340 ms
6,676 KB
testcase_04 AC 571 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 56 ms
6,676 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 693 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 670 ms
6,676 KB
testcase_26 AC 673 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0