Pagini recente » Cod sursa (job #1403092) | Cod sursa (job #149713) | Cod sursa (job #357779) | Cod sursa (job #205848) | Cod sursa (job #1809066)
#include <fstream>
std::ifstream in ( "kperm.in" );
std::ofstream out( "kperm.out" );
const int MOD = 666013;
int fct( int x ) {
if( x == 0 ) { return 1; }
else { return ( x * 1LL * fct( x - 1 ) ) % MOD; } }
int pow( int x, int y ) {
if( y == 0 ) { return 1; }
else { return ( x * 1LL * pow( x, y - 1 ) ) % MOD; } }
int main( int argc, const char *argv[] ) {
std::ios::sync_with_stdio( false );
int n, k, ans = 1; in >> n >> k;
ans = ( ans * 1LL * fct(n % k) ) % MOD;
ans = ( ans * 1LL * fct(k - n % k) ) % MOD;
ans = ( ans * 1LL * pow(fct(n / k + 1), n % k) );
ans = ( ans * 1LL * pow(fct(n / k), n - n % k) );
out << ans * (k % 2) << std::endl;
return 0; }