Pagini recente » Cod sursa (job #197230) | Cod sursa (job #2240231) | Cod sursa (job #1177387) | Cod sursa (job #966625) | Cod sursa (job #478399)
Cod sursa(job #478399)
#include <cstdio>
const int maxN = 100100;
const int mod = 1000000007;
using namespace std;
int N, K;
long long sol;
int S[maxN];
int main() {
int i, a, b;
freopen("colorare3.in", "r", stdin);
freopen("colorare3.out", "w", stdout);
scanf("%d%d", &N, &K);
sol = 1;
for (i = 1; i < N; i++) {
scanf("%d%d", &a, &b);
sol = (sol * 1LL * (K - S[a] - S[b])) % mod;
S[a]++;
S[b]++;
}
printf("%lld\n", sol);
return 0;
}