Pagini recente » Cod sursa (job #2791498) | Cod sursa (job #2969394) | Cod sursa (job #2313049) | Cod sursa (job #1292061) | Cod sursa (job #1809061)
#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 << std::endl;
return 0; }