結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 14:38:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,327 bytes |
| コンパイル時間 | 1,941 ms |
| コンパイル使用メモリ | 180,348 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-30 19:46:15 |
| 合計ジャッジ時間 | 4,044 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using ll=long long;
#define rep(i,s,n) for (ll i = (s); i < (n); i++)
using namespace std;
using Graph = vector<vector<ll>>;
ll MOD=998244353;
const ll INF=1e18;
ll mod;
ll modpow(ll a,ll n){
ll res=1;
while(n>0){
if(n&1) res=(res*a)%mod;
a=(a*a)%mod;
n>>=1;
}
return res;
}
int main(){
ll N,P,Q;
cin>>N>>P>>Q;
mod=P;
vector<ll> A(N);
rep(i,0,N){
cin>>A[i];
}
vector<vector<ll>> L(3,vector<ll> (N));
vector<pair<ll,ll>> X(N);
rep(i,0,N){
L[0][i]=modpow(10,A[i]);
}
rep(i,0,N){
L[1][i]=modpow(9,A[i]);
}
rep(i,0,N){
L[2][i]=modpow(7,A[i]);
}
rep(i,0,N){
X[i]={modpow(5,A[i]),i};
}
sort(X.begin(), X.end());
ll ans=0;
rep(i,0,N){
rep(j,0,N){
rep(k,0,N){
if(!(i<j&&j<k)) continue;
ll s=L[0][i]+L[1][j]+L[2][k];
s%=mod;
ll a=(Q+mod-s)%mod;
ll l=distance(X.begin(), lower_bound(X.begin(), X.end(), make_pair(a,(ll)0)));
ll r=distance(X.begin(), lower_bound(X.begin(), X.end(), make_pair(a+1,(ll)0)));
//cout<<a<<endl;
if(X[l].first==a){
rep(x,l,r){
if(k<X[x].second){
ans++;
//cout<<i<<j<<k<<X[x].first<<X[x].second<<endl;
}
}
}
}
}
}
cout<<ans<<endl;
}