Pagini recente » Statistici Tudor George Alexandru (AlexandruTudor) | Profil StefanBad | Cod sursa (job #158839) | Cod sursa (job #478056) | Cod sursa (job #548879)
Cod sursa(job #548879)
#include<fstream>
#include<vector>
using namespace std;
const int maxn = 100005;
const int mod = 1000000007;
ifstream fin("colorare3.in");
ofstream fout("colorare3.out");
int i , j , a , b , n , k , dg[maxn] , ans;
bool seen[maxn];
int main()
{
for( fin >> n >> k, i = 1 ; i < n ; ++i )
fin >> a >> b,
dg[a]++,
dg[b]++;
ans = k;
for( i = 1 ; i <= n ; ++i )
for( j = 1 ; j < dg[i] ; ++j )
ans = ans * ( k - j ) % mod;
fout << ans << "\n";
return 0;
}