結果

問題 No.2709 1975 Powers
ユーザー BBhorseBBhorse
提出日時 2024-03-31 14:38:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,327 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 179,568 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:38:10
合計ジャッジ時間 4,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 5 ms
6,676 KB
testcase_03 AC 90 ms
6,676 KB
testcase_04 AC 148 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 23 ms
6,676 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 168 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 171 ms
6,676 KB
testcase_26 AC 172 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  
}
0