Cod sursa(job #2277621)
| Utilizator | Data | 6 noiembrie 2018 17:26:46 | |
|---|---|---|---|
| Problema | Matrice5 | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <fstream>
#define MOD 10007
using namespace std;
std::ifstream INPUT_FILE("matrice5.in");
std::ofstream OUTPUT_FILE("matrice5..out");
int powaOfTheMathSide(int a,int putere){
long rez=1;
while(putere){
if(putere&1) rez=(1LL*rez*a)%MOD;
a=(1LL*a*a)%MOD;
putere>>=1;
}
return rez;
}
int main() {
int T;
INPUT_FILE>>T;
for(int tmp=0;tmp<T;++tmp){
int N,M,P,K;
INPUT_FILE>>N>>M>>P>>K;
OUTPUT_FILE<<(powaOfTheMathSide(P,M*N)*powaOfTheMathSide(K,(M-1)*(N-1)))%MOD<<"\n";
}
return 0;
}