結果

問題 No.2709 1975 Powers
ユーザー umezoumezo
提出日時 2024-03-31 14:02:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 3,117 ms
コンパイル使用メモリ 255,756 KB
実行使用メモリ 814,764 KB
最終ジャッジ日時 2024-03-31 14:02:51
合計ジャッジ時間 5,324 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>; //B(n,V<int>(n))
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,p,q;
  cin>>n>>p>>q;
  V<ll> A(n);
  rep(i,n) cin>>A[i];
  sort(ALL(A));
  
  VV<ll> B(4,V<ll>(2002002));
  rep(i,4) B[i][0]=1;
  rep(j,2002000) B[0][j+1]=B[0][j]*10%p;
  rep(j,2002000) B[1][j+1]=B[1][j]*9%p;
  rep(j,2002000) B[2][j+1]=B[2][j]*7%p;
  rep(j,2002000) B[3][j+1]=B[3][j]*5%p;
  
  VV<ll> C(n+1,V<ll>(2002002));
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<2002002;j++){
      C[i][j]=C[i+1][j];
    }
    C[i][B[3][A[i]]]++;
  }
  
  ll ans=0;
  for(int a=0;a<n-1;a++){
    for(int b=a+1;b<n-1;b++){
      for(int c=b+1;c<n-1;c++){
        ll tmp=(B[0][A[a]]+B[1][A[b]]+B[2][A[c]])%p;
        ans+=C[c+1][(q-tmp+p)%p];
      }
    }
  }
  cout<<ans<<endl;
  
    
  return 0;
}
0