結果
問題 | No.2709 1975 Powers |
ユーザー |
|
提出日時 | 2024-03-31 13:41:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 762 bytes |
コンパイル時間 | 987 ms |
コンパイル使用メモリ | 86,996 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 18:15:00 |
合計ジャッジ時間 | 2,272 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include<iostream> #include<algorithm> #include<map> #include<cassert> #include<atcoder/modint> using namespace std; using mint=atcoder::modint; int N,P,Q; int A[200]; mint T[200][4]; map<int,int>L[200]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>P>>Q; mint::set_mod(P); for(int i=0;i<N;i++)cin>>A[i]; sort(A,A+N); for(int i=0;i<N;i++) { T[i][0]=mint(10).pow(A[i]); T[i][1]=mint(9).pow(A[i]); T[i][2]=mint(7).pow(A[i]); T[i][3]=mint(5).pow(A[i]); } for(int i=0;i<N;i++)for(int j=i+1;j<N;j++) { L[j][(T[i][0]+T[j][1]).val()]++; } long ans=0; for(int l=0;l<N;l++)for(int i=l+1;i<N;i++)for(int j=i+1;j<N;j++) { int t=(Q-(T[i][2]+T[j][3])).val(); if(L[l].find(t)!=L[l].end())ans+=L[l][t]; } cout<<ans<<endl; }