結果

問題 No.2394 部分和乗総和
ユーザー Nzt3
提出日時 2023-09-27 17:04:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 194,736 KB
最終ジャッジ日時 2025-02-17 02:37:55
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

ll modpow(long long a,int n,int mod){
  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);
  int N;
  ll M,B;
  cin>>N>>M>>B;
  M%=B;
  vector A(N,0ll);
  for(ll &i:A)cin>>i;
  ll ans=1;
  for(int i=0;i<N;i++){
    ans=ans*(modpow(M,A[i],B)+1)%B;
  }
  cout<<ans<<'\n';
}
0