Cod sursa(job #1960451)
Utilizator | Data | 10 aprilie 2017 13:58:58 | |
---|---|---|---|
Problema | Matrice5 | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <cstdio>
using namespace std;
const int Mod = 10007;
int q, n, m, p, k;
int power(int a, int b)
{
if(!b) return 1;
if(b&1) return a * power(a*a%Mod, b/2) % Mod;
return power(a*a%Mod, b/2);
}
int main()
{
freopen("matrice5.in", "r", stdin);
freopen("matrice5.out", "w", stdout);
scanf("%d", &q);
while(q--)
{
scanf("%d%d%d%d", &n, &m, &p, &k);
printf("%d\n", power(k, n*m-n-m+1) * power(p, n*m) % Mod);
}
return 0;
}