結果
問題 | No.2709 1975 Powers |
ユーザー | Nzt3 |
提出日時 | 2024-03-31 14:13:25 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,668 ms / 2,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 2,068 ms |
コンパイル使用メモリ | 212,136 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-09-30 19:11:26 |
合計ジャッジ時間 | 20,458 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; ll MOD; namespace Lib{ ll modpow(ll a,ll n){ long long ret=1,t=a; while(n>0){ if(n&1)ret=ret*t%MOD; t=t*t%MOD; n/=2; } return ret; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N,P,Q; cin>>N>>P>>Q; MOD=P; vector A(N,0); for(int &i:A)cin>>i; sort(A.begin(),A.end()); map<ll,int>cnt; ll ans=0; for(int c=N-1;c>=0;c--){ for(int a=0;a<c;a++){ for(int b=a+1;b<c;b++){ ll x=Lib::modpow(10,A[a])+Lib::modpow(9,A[b])+Lib::modpow(7,A[c]); ans+=cnt[((Q-x)%P+P)%P]; } } cnt[Lib::modpow(5,A[c])]+=1; } cout<<ans<<'\n'; }