Cod sursa(job #1788157)
Utilizator | Data | 25 octombrie 2016 18:52:07 | |
---|---|---|---|
Problema | Matrice5 | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
using namespace std;
int t,n,m,p,k;
int pu(int q, int x)
{
int p=1;
while(x)
{
if(x%2) p*=q;
q*=q;
x/=2;
p=p%10007;
q=q%10007;
}
return p;
}
int main()
{
ifstream f("matrice5.in");
ofstream g("matrice5.out");
f>>t;
while(t)
{
t--;
f>>n>>m>>p>>k;
g<<pu(p,m*n)*pu(k,(m-1)*(n-1))%10007<<'\n';
}
f.close(); g.close();
return 0;
}