結果
問題 | No.1302 Random Tree Score |
ユーザー | kyort0n |
提出日時 | 2020-11-28 01:25:30 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 496 ms / 3,000 ms |
コード長 | 1,583 bytes |
コンパイル時間 | 5,454 ms |
コンパイル使用メモリ | 208,664 KB |
実行使用メモリ | 11,132 KB |
最終ジャッジ日時 | 2023-10-09 23:12:30 |
合計ジャッジ時間 | 8,842 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,352 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 89 ms
4,992 KB |
testcase_03 | AC | 219 ms
7,292 KB |
testcase_04 | AC | 85 ms
5,312 KB |
testcase_05 | AC | 496 ms
10,908 KB |
testcase_06 | AC | 400 ms
10,256 KB |
testcase_07 | AC | 82 ms
5,344 KB |
testcase_08 | AC | 246 ms
7,504 KB |
testcase_09 | AC | 383 ms
10,256 KB |
testcase_10 | AC | 405 ms
10,316 KB |
testcase_11 | AC | 79 ms
5,240 KB |
testcase_12 | AC | 458 ms
10,736 KB |
testcase_13 | AC | 2 ms
4,352 KB |
testcase_14 | AC | 386 ms
10,888 KB |
testcase_15 | AC | 449 ms
11,132 KB |
testcase_16 | AC | 2 ms
4,348 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/convolution> #define endl "\n" using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long long INF = 1e18; const ll mod = 998244353; using mint = atcoder::modint998244353; ll N; mint Factorial[105000]; vector<mint> mul(vector<mint> a, vector<mint> b) { vector<mint> ret = atcoder::convolution(a, b); ret.resize(N - 1); return ret; } vector<mint> power(vector<mint> v, ll x) { vector<mint> ret; ret.push_back(1); vector<mint> factor = v; ll idx = 0; while(x) { if(x & (1LL << idx)) { ret = mul(ret, factor); x -= (1LL << idx); } factor = mul(factor, factor); idx++; } return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); Factorial[0] = 1; cin >> N; for(ll i = 1; i <= N; i++) { Factorial[i] = Factorial[i-1] * i; //cerr << i << " " << Factorial[i].val() << endl; } vector<mint> v; for(int i = 0; i <= N - 2; i++) { v.push_back((i + 1) / Factorial[i]); } auto u = power(v, N); mint ans = u[N-2]; ans *= Factorial[N-2]; mint factor = 1; for(int i = 0; i < N - 2; i++) factor *= N; ans /= factor; cout << ans.val() << endl; return 0; }