Cod sursa(job #3304203)

Utilizator Iustin_Mircea2010Iustin Mircea Iustin_Mircea2010 Data 21 iulie 2025 18:29:52
Problema Matrice5 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod = 1e4 + 7;

int binexp(int b, int e){
    int ans = 1;
    while(e){
        if(e & 1){
            ans = ans * b % mod;
        }
        b = b * b % mod;
        e >>= 1;
    }
    return ans;
}

signed main(){
    
    int t;
    cin >> t;
    while(t--){
        int n, m, p, k;
        cin >> n >> m >> p >> k;
        cout << binexp(p * k % mod, (n - 1) * (m - 1)) * binexp(p, n + m - 1) % mod << '\n';
    }
    
    return 0;
}