結果

問題 No.827 総神童数
ユーザー kotatsugamekotatsugame
提出日時 2019-05-04 01:28:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 70,584 KB
実行使用メモリ 27,788 KB
最終ジャッジ日時 2023-08-30 20:49:25
合計ジャッジ時間 9,218 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,564 KB
testcase_01 AC 5 ms
9,504 KB
testcase_02 AC 4 ms
9,644 KB
testcase_03 AC 5 ms
9,484 KB
testcase_04 AC 5 ms
9,468 KB
testcase_05 AC 5 ms
9,536 KB
testcase_06 AC 4 ms
9,448 KB
testcase_07 AC 4 ms
9,392 KB
testcase_08 AC 5 ms
9,540 KB
testcase_09 AC 364 ms
27,788 KB
testcase_10 AC 125 ms
15,020 KB
testcase_11 AC 9 ms
9,752 KB
testcase_12 AC 56 ms
12,324 KB
testcase_13 AC 288 ms
24,788 KB
testcase_14 AC 15 ms
10,288 KB
testcase_15 AC 115 ms
15,404 KB
testcase_16 AC 291 ms
20,604 KB
testcase_17 AC 346 ms
23,452 KB
testcase_18 AC 148 ms
16,892 KB
testcase_19 AC 381 ms
16,408 KB
testcase_20 AC 270 ms
14,580 KB
testcase_21 AC 191 ms
13,412 KB
testcase_22 AC 299 ms
15,036 KB
testcase_23 AC 6 ms
9,572 KB
testcase_24 AC 329 ms
15,612 KB
testcase_25 AC 242 ms
14,096 KB
testcase_26 AC 340 ms
15,728 KB
testcase_27 AC 217 ms
13,680 KB
testcase_28 AC 218 ms
13,472 KB
testcase_29 AC 166 ms
12,812 KB
testcase_30 AC 52 ms
10,512 KB
testcase_31 AC 131 ms
12,200 KB
testcase_32 AC 125 ms
11,928 KB
testcase_33 AC 373 ms
16,224 KB
testcase_34 AC 337 ms
15,576 KB
testcase_35 AC 131 ms
12,288 KB
testcase_36 AC 191 ms
13,036 KB
testcase_37 AC 245 ms
14,068 KB
testcase_38 AC 361 ms
16,000 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:15:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   15 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
long mod=1e9+7,F=1,ans;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int d[2<<17];
vector<int>G[2<<17];
void dfs(int u,int p,int di)
{
	d[u]=di;
	for(int i=0;i<G[u].size();i++)
		if(G[u][i]!=p)dfs(G[u][i],u,di+1);
}
int N;
main()
{
	cin>>N;
	for(int i=1;i++<N;)
	{
		F=F*i%mod;
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,-1,1);
	for(int i=0;i<N;i++)ans+=power(d[i],mod-2);
	cout<<ans%mod*F%mod<<endl;
}
0