Cod sursa(job #2021297)

Utilizator PopoviciRobertPopovici Robert PopoviciRobert Data 13 septembrie 2017 09:49:59
Problema Colorare3 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <bits/stdc++.h>

const int MAXN = (int) 1e5;
const int MOD = (int) 1e9 + 7;

int deg[MAXN + 1];

int main() {
    FILE *fi, *fout;
    int i, n, a, b, k, j;
    fi = fopen("colorare3.in" ,"r");
    fout = fopen("colorare3.out" ,"w");
    fscanf(fi,"%d %d " ,&n,&k);
    for(i = 1; i < n; i++) {
        fscanf(fi,"%d %d " ,&a,&b);
        deg[a]++;
        deg[b]++;
    }
    int ans = 1;
    for(i = 1; i <= n; i++) {
        int x = 1;
        if(i == 1)
            x = 0;
        for(j = k - deg[i] + 1; j <= k - x; j++)
            ans = (1LL * ans * j) % MOD;
    }
    fprintf(fout,"%d" ,ans);
    fclose(fi);
    fclose(fout);
    return 0;
}