Pagini recente » Rating super qa (bongdayeah) | Cod sursa (job #190312) | Cod sursa (job #16727) | Cod sursa (job #402725) | Cod sursa (job #2223880)
#include<fstream>
#include<cstring>
#include<iostream>
#define DN 2005
#define M 10007
using namespace std;
ifstream fin("matrice5.in");
ofstream fout("matrice5.out");
int t,n,m,p,k,rez,f;
int main()
{
fin>>t;
while(t--)
{
fin>>n>>m>>p>>k;
rez=1;
for(int i=1;i<m;i++)
rez=(1LL*rez*k*p)%M;
rez=(1LL*rez*p)%M;
// cout<<rez<<'\n';
if(n==1)
{
fout<<rez<<'\n';
continue;
}
f=rez;
rez=1;
for(int i=1;i<n;i++)
rez=(1LL*rez*f)%M;
for(int i=1;i<=m;i++)
rez=(1LL*rez*p)%M;
fout<<rez<<'\n';
}
}