結果
問題 | No.2394 部分和乗総和 |
ユーザー |
|
提出日時 | 2023-09-27 17:05:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 448 bytes |
コンパイル時間 | 1,704 ms |
コンパイル使用メモリ | 195,264 KB |
最終ジャッジ日時 | 2025-02-17 02:38:02 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;ll modpow(ll a,ll 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';}