Cod sursa(job #729878)
| Utilizator | Data | 30 martie 2012 17:07:54 | |
|---|---|---|---|
| Problema | Matrice5 | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<iostream>
#include<fstream>
#define M 10007
using namespace std;
ifstream in("matrice5.in");
ofstream out("matrice5.out");
int t,n,m,k,p;
inline int pu(int nr, int p) {
int rez = 1, t = nr;
while(p) {
if(p&1)
rez=(rez*t)%M;
t = (t*t)%M;
p>>=1;
}
return rez;
}
int main() {
in >> t;
while(t--) {
in >> n >> m >> p >> k;
out << (pu(p, n*m) * pu(k, (n-1)*(m-1)))%M << "\n";
}
return 0;
}
