結果

問題 No.3153 probability max K
ユーザー umezo
提出日時 2025-05-21 02:47:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 3,381 ms
コンパイル使用メモリ 275,236 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-21 02:47:45
合計ジャッジ時間 6,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;

const int MOD=998244353;
ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x%MOD;
    x=x*x%MOD;
    n/=2;
  }
  return ans;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,k;
  cin>>n>>k;
  V<ll> A(n);
  rep(i,n) cin>>A[i];
  ll a=1,b=1;
  rep(i,n) a=a*min(k,A[i])%MOD*modpow(A[i],MOD-2)%MOD;
  rep(i,n) b=b*min(k-1,A[i])%MOD*modpow(A[i],MOD-2)%MOD;
  cout<<(a-b+MOD)%MOD<<endl;
    
  return 0;
}
0