結果

問題 No.2709 1975 Powers
ユーザー umezoumezo
提出日時 2024-03-31 14:27:49
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 1,006 bytes
コンパイル時間 3,133 ms
コンパイル使用メモリ 255,756 KB
実行使用メモリ 223,952 KB
最終ジャッジ日時 2024-03-31 14:28:08
合計ジャッジ時間 11,455 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
81,388 KB
testcase_01 AC 161 ms
81,388 KB
testcase_02 AC 202 ms
112,848 KB
testcase_03 AC 295 ms
199,632 KB
testcase_04 AC 371 ms
217,680 KB
testcase_05 AC 325 ms
203,600 KB
testcase_06 AC 271 ms
169,168 KB
testcase_07 AC 170 ms
81,612 KB
testcase_08 AC 266 ms
166,864 KB
testcase_09 AC 334 ms
203,600 KB
testcase_10 AC 170 ms
82,380 KB
testcase_11 AC 210 ms
122,192 KB
testcase_12 AC 227 ms
138,704 KB
testcase_13 AC 345 ms
205,136 KB
testcase_14 AC 242 ms
151,120 KB
testcase_15 AC 250 ms
154,320 KB
testcase_16 AC 316 ms
195,792 KB
testcase_17 AC 185 ms
95,692 KB
testcase_18 AC 234 ms
143,312 KB
testcase_19 AC 367 ms
216,912 KB
testcase_20 AC 198 ms
107,344 KB
testcase_21 AC 266 ms
166,096 KB
testcase_22 AC 339 ms
223,952 KB
testcase_23 AC 386 ms
223,952 KB
testcase_24 AC 394 ms
223,952 KB
testcase_25 AC 389 ms
223,952 KB
testcase_26 AC 374 ms
223,952 KB
権限があれば一括ダウンロードができます

ソースコード

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>(100100));
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<100100;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