結果
| 問題 | No.1302 Random Tree Score |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2026-11-04 00:06:32 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 453 ms / 3,000 ms |
| + 152µs | |
| コード長 | 808 bytes |
| 記録 | |
| コンパイル時間 | 5,739 ms |
| コンパイル使用メモリ | 386,032 KB |
| 実行使用メモリ | 9,872 KB |
| 最終ジャッジ日時 | 2026-11-04 00:06:44 |
| 合計ジャッジ時間 | 11,793 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint=modint998244353;
#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>>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin>>n;
mint ans=1;
rep(i,n-2) ans*=(mint)(i+1)/n;
V<mint> fac(n),A(n),B(n);
fac[0]=1,fac[1]=1;
for(int i=2;i<n;i++) fac[i]=i*fac[i-1];
B[0]=1;
rep(i,n) A[i]=(i+1)/fac[i];
ll m=n;
while(m){
if(m&1){
auto C=convolution(A,B);
C.resize(n);
swap(B,C);
}
auto D=convolution(A,A);
D.resize(n);
swap(D,A);
m/=2;
}
ans*=B[n-2];
cout<<ans.val()<<endl;
return 0;
}
umezo