結果
問題 |
No.2083 OR Subset
|
ユーザー |
|
提出日時 | 2025-10-10 15:53:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 666 ms / 3,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 3,928 ms |
コンパイル使用メモリ | 162,096 KB |
実行使用メモリ | 393,384 KB |
最終ジャッジ日時 | 2025-10-10 15:54:06 |
合計ジャッジ時間 | 10,145 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; const int mod=998244353; int n,C[5005][5005],S[5005][5005],pw[5005],ans=0; int qpow(int a,int b){ int ans=1;a%=mod; while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;} return ans; } signed main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n,C[0][0]=S[0][0]=pw[0]=1; for(int i=1;i<=n;i++){C[i][0]=1,pw[i]=pw[i-1]*2%mod;for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod,S[i][j]=(S[i-1][j-1]+j*S[i-1][j])%mod;} for(int i=0;i<=n;i++)for(int j=0;j<=i;j++)(ans+=C[n][i]*S[i][j]%mod*qpow(pw[j]-j+mod,n-i))%=mod; cout<<ans; return 0; }