Cod sursa(job #2133148)
Utilizator | Data | 16 februarie 2018 16:38:36 | |
---|---|---|---|
Problema | Matrice5 | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <bits/stdc++.h>
using namespace std;
const int modulo = 10007;
int putere(int a,int b)
{
int rez = 1;
while(b != 0)
{
if(b % 2 == 1)
rez = (rez*a)%modulo;
a = (a*a)%modulo;
b /= 2;
}
return rez;
}
int main()
{
freopen("matrice5.in","r",stdin);
freopen("matrice5.out","w",stdout);
int test;
cin >> test;
while(test > 0)
{
int n,m,p,k;
cin >> n >> m >> p >> k;
int ans = (putere((k*p)%modulo, (n-1)*(m-1))* putere(p, n+m-1)) % modulo;
cout << ans << "\n";
test --;
}
return 0;
}