結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-03-31 15:57:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 862 ms / 2,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 2,270 ms |
| コンパイル使用メモリ | 196,148 KB |
| 最終ジャッジ日時 | 2025-02-20 18:02:14 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int N,P,Q,A[200];
const int M=2e6;
long p1[1<<21],p9[1<<21],p7[1<<21],p5[1<<21];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>P>>Q;
for(int i=0;i<N;i++)cin>>A[i];
sort(A,A+N);
p1[0]=p9[0]=p7[0]=p5[0]=1;
for(int i=1;i<=M;i++)
{
p1[i]=(p1[i-1]*10)%P;
p9[i]=(p9[i-1]*9)%P;
p7[i]=(p7[i-1]*7)%P;
p5[i]=(p5[i-1]*5)%P;
}
int ans=0;
for(int i=0;i<N;i++)for(int j=0;j<i;j++)for(int k=0;k<j;k++)for(int l=0;l<k;l++)
{
if((p1[A[l]]+p9[A[k]]+p7[A[j]]+p5[A[i]])%P==Q)ans++;
}
cout<<ans<<'\n';
}
nonon