結果

問題 No.2709 1975 Powers
ユーザー twooimp2twooimp2
提出日時 2024-04-01 02:19:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 693 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 6,804 ms
コンパイル使用メモリ 305,636 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-01 02:19:51
合計ジャッジ時間 14,868 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 6 ms
6,676 KB
testcase_03 AC 340 ms
6,676 KB
testcase_04 AC 566 ms
6,676 KB
testcase_05 AC 382 ms
6,676 KB
testcase_06 AC 120 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 110 ms
6,676 KB
testcase_09 AC 382 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 12 ms
6,676 KB
testcase_12 AC 30 ms
6,676 KB
testcase_13 AC 401 ms
6,676 KB
testcase_14 AC 54 ms
6,676 KB
testcase_15 AC 64 ms
6,676 KB
testcase_16 AC 302 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 38 ms
6,676 KB
testcase_19 AC 554 ms
6,676 KB
testcase_20 AC 4 ms
6,676 KB
testcase_21 AC 105 ms
6,676 KB
testcase_22 AC 692 ms
6,676 KB
testcase_23 AC 667 ms
6,676 KB
testcase_24 AC 693 ms
6,676 KB
testcase_25 AC 667 ms
6,676 KB
testcase_26 AC 668 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];
  }
  sort(a.begin(),a.end());
  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