Cod sursa(job #3304184)
| Utilizator | Data | 21 iulie 2025 16:24:00 | |
|---|---|---|---|
| Problema | Matrice5 | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream fin("matrice5.in");
ofstream fout("matrice5.out");
const int MOD=1e4+7;
typedef long long ll;
int lgpow(int nr,int exponent) {
int res=1;
while(exponent) {
if(exponent&1) {
res=(ll)res*nr%MOD;
}
exponent/=2;
nr=(ll)nr*nr%MOD;
}
return res;
}
int main() {
int t,n,m,p,k;
fin>>t;
while(t--) {
fin>>n>>m>>p>>k;
int res=(ll)lgpow(p*k,(n-1)*(m-1))*lgpow(p,n+m-1)%MOD;
fout<<res<<'\n';
}
return 0;
}
