結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2024-03-31 14:27:49 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 437 ms / 2,000 ms |
| コード長 | 1,006 bytes |
| コンパイル時間 | 2,642 ms |
| コンパイル使用メモリ | 255,300 KB |
| 実行使用メモリ | 223,832 KB |
| 最終ジャッジ日時 | 2024-09-30 19:34:07 |
| 合計ジャッジ時間 | 11,443 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#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;
}
umezo