Cod sursa(job #3263750)
| Utilizator | Data | 16 decembrie 2024 11:45:30 | |
|---|---|---|---|
| Problema | Matrice5 | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
#define int long long
using namespace std;
ifstream in("matrice5.in");
ofstream out("matrice5.out");
const int MOD = 1e4+7;
int q, n, m, k, p;
int quickpow(int x, int a)
{
int p = 1;
while(a)
{
if (a%2) p = (p*x)%MOD;
x = (x*x)%MOD;
a /= 2;
}
return p;
}
int32_t main()
{
in >> q;
while(q)
{
q--;
in >> n >> m >> p >> k;
out << (quickpow(p, n*m) * quickpow(k, (m-1)*(n-1)))%MOD << '\n';
}
}
