結果
問題 | No.827 総神童数 |
ユーザー | kappybar |
提出日時 | 2020-04-14 14:24:59 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,178 bytes |
コンパイル時間 | 2,416 ms |
コンパイル使用メモリ | 169,348 KB |
実行使用メモリ | 23,500 KB |
最終ジャッジ日時 | 2024-04-09 05:21:07 |
合計ジャッジ時間 | 11,354 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
8,756 KB |
testcase_01 | AC | 6 ms
8,652 KB |
testcase_02 | AC | 6 ms
8,828 KB |
testcase_03 | AC | 6 ms
8,652 KB |
testcase_04 | AC | 5 ms
8,876 KB |
testcase_05 | AC | 6 ms
8,856 KB |
testcase_06 | AC | 6 ms
8,764 KB |
testcase_07 | AC | 6 ms
8,820 KB |
testcase_08 | AC | 7 ms
8,784 KB |
testcase_09 | AC | 360 ms
23,500 KB |
testcase_10 | AC | 124 ms
13,368 KB |
testcase_11 | AC | 11 ms
8,900 KB |
testcase_12 | AC | 53 ms
11,304 KB |
testcase_13 | AC | 285 ms
21,080 KB |
testcase_14 | AC | 16 ms
9,328 KB |
testcase_15 | AC | 115 ms
13,732 KB |
testcase_16 | AC | 285 ms
17,944 KB |
testcase_17 | AC | 337 ms
20,112 KB |
testcase_18 | AC | 145 ms
14,672 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 197 ms
11,976 KB |
testcase_22 | WA | - |
testcase_23 | AC | 8 ms
8,892 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll = long long ; using P = pair<int,int> ; const ll INF = 1e14; const int MOD = 1000000007; int n = 200005; vector<vector<int>> tree(n); vector<int> depth(n,0); void dfs(int i,int p=-1,int d=0){ depth[d] ++; for(int c:tree[i]){ if(c==p) continue; dfs(c,i,d+1); } } long long modpow(long long a, long long b,long long mod){ bitset<30> bit(b); string s = bit.to_string(); long long ret = 1; for (int i = 0;i< s.length(); ++i){ ret = (ret * ret) % mod; if(s[i]-'0') ret = (ret * a) % mod; } return ret; } long long inverse(long long x,long long mod){ return modpow(x,mod-2,mod); } int main(){ cin >> n; rep(i,n-1){ int a,b; cin >> a >> b; --a;--b; tree[a].push_back(b); tree[b].push_back(a); } dfs(0); ll ans = 0; ll n_p = 1; for(ll i=1;i<=n;i++) n_p = (n_p * i)%MOD; for(ll i=0;i<n;i++){ ans = (ans + n_p * (inverse(i+1,MOD) * depth[i])%MOD)%MOD; } cout << ans << endl; return 0; }