Pagini recente » Cod sursa (job #3191129) | Cod sursa (job #2722997) | Cod sursa (job #3192189) | Cod sursa (job #270151) | Cod sursa (job #1415931)
#include <fstream>
#define MOD 10007
using namespace std;
ifstream is("matrice5.in");
ofstream os("matrice5.out");
int t;
int n, m, p, k;
int sol;
int Fact( int a, int b );
int main()
{
is >> t;
for ( int i = 1; i <= t; i++ )
{
is >> n >> m >> p >> k;
sol = ( Fact( p, n * m ) * Fact( k, (n-1) * (m-1) ) ) % MOD;
os << sol << '\n';
}
is.close();
os.close();
return 0;
}
int Fact( int a, int b )
{
if ( b == 1 ) return a;
if ( b == 0 ) return 1;
int aux = Fact( a, b / 2 );
aux = ( aux * aux ) % MOD;
if ( b % 2 )
aux = (aux * a) % MOD;
return aux;
}