結果

問題 No.2709 1975 Powers
ユーザー harurunharurun
提出日時 2024-03-31 14:53:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,289 bytes
コンパイル時間 9,342 ms
コンパイル使用メモリ 422,320 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:53:32
合計ジャッジ時間 25,850 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 41 ms
6,676 KB
testcase_03 AC 925 ms
6,676 KB
testcase_04 AC 1,369 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 232 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 1,591 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,589 ms
6,676 KB
testcase_26 AC 1,594 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <stack>
#include <random>
#include <complex>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#if __has_include(<boost/multiprecision/cpp_int.hpp>)
#include <boost/multiprecision/cpp_int.hpp>
using cpp_int=boost::multiprecision::cpp_int;
#endif
#if __has_include(<boost/multiprecision/cpp_dec_float.hpp>)
#include <boost/multiprecision/cpp_dec_float.hpp>
template<unsigned size>using cpp_float=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<size>>;
template<unsigned size>using cpp_double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<size,long long>>;
#endif
using namespace std;
using ll=long long;
#define read(x) cin>>(x);
#define readll(x) ll (x);cin>>(x);
#define readS(x) string (x);cin>>(x);
#define readvll(x,N) vector<ll> (x)((N));for(int i=0;i<(N);i++){cin>>(x)[i];}
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define rep2d(i,j,H,W) for(ll (i)=0;(i)<(H);(i)++)for(ll (j)=0;(j)<(W);j++)
#define is_in(x,y) (0<=(x) && (x)<H && 0<=(y) && (y)<W)
#define yn {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define double_out(x) fixed << setprecision(x)
template<class T> inline void erase_duplicate(vector<T>& A){sort(A.begin(),A.end());A.erase(unique(A.begin(),A.end()),A.end());}
inline ll powll(ll x,ll n){ll r=1;while(n>0){if(n&1){r*=x;};x*=x;n>>=1;};return r;}

inline ll pow_mod(ll x,ll n,ll mod){ll r=1;while(n>0){if(n&1){r*=x;r%=mod;};x*=x;x%=mod;n>>=1;};return r;}

int main(){
  ll N,P,Q;
  cin>>N>>P>>Q;
  vector<ll> A(N);
  vector<ll> five(N);
  for(ll i=0;i<N;i++){
    cin>>A[i];
    five[i]=pow_mod(5,A[i],P);
  }
  vector<ll> cnt(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++){
        ll C=pow_mod(10,A[i],P)+pow_mod(9,A[j],P)+pow_mod(7,A[k],P);
        C%=P;
        if(k+1<N){
          cnt[five[k+1]]++;
          ans+=cnt[(P+Q-C)%P];
        }
      }
    }
  }
  cout<<ans<<endl;
}
0