Pagini recente » Cod sursa (job #1014786) | Cod sursa (job #2651995) | Lista lu' Francu | Cod sursa (job #98423) | Cod sursa (job #468603)
Cod sursa(job #468603)
#include <cstdio>
int N, D, p[ 6 ], x, K, rez;
void solve()
{
x = N - K;
while ( x % 2 == 0 )
x /= 2, p[ 2 ] ++;
while ( x % 3 == 0 )
x /= 3, p[ 3 ] ++;
while ( x % 5 == 0 )
x /= 5, p[ 5 ] ++;
x = K + 1;
while ( x % 2 == 0 )
x /= 2, p[ 2 ] --;
while ( x % 3 == 0 )
x /= 3, p[ 3 ] --;
while ( x % 5 == 0 )
x /= 5, p[ 5 ] --;
if ( D == 2 )
rez += ( p[ 2 ] >= 1 );
if ( D == 3 )
rez += ( p[ 3 ] >= 1 );
if ( D == 4 )
rez += ( p[ 2 ] >= 2 );
if ( D == 5 )
rez += ( p[ 5 ] >= 1 );
if ( D == 6 )
rez += ( p[ 2 ] >= 1 && p[ 3 ] >= 1 );
}
int main()
{
freopen( "pascal.in", "r", stdin );
freopen( "pascal.out", "w", stdout );
scanf( "%d%d", &N, &D );
for ( K = 0; K < ( ( N + 1 ) >> 1 ) - 1; K++ )
solve();
rez *= 2;
if ( N % 2 == 0 )
solve();
printf( "%d\n", rez );
return 0;
}