Cod sursa(job #2949742)

Utilizator hhhhhhhAndrei Boaca hhhhhhh Data 1 decembrie 2022 16:14:09
Problema Matrice5 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("matrice5.in");
ofstream fout("matrice5.out");
const int mod=10007;
int t;
int pw(int a,int b)
{
    int rez=1;
    while(b)
    {
        if(b&1)
            rez=(rez*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return rez;
}
int n,m,p,k;
void solve()
{
    fin>>n>>m>>p>>k;
    int r1=pw(k,(n-1)*(m-1)%(mod-2));
    int r2=pw(p,(n*m)%(mod-2));
    fout<<(r1*r2)%mod<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    fin.tie(0);
    fin>>t;
    while(t--)
        solve();
    return 0;
}