Pagini recente » Cod sursa (job #1457499) | Cod sursa (job #1540312) | Cod sursa (job #130425) | Cod sursa (job #962006) | Cod sursa (job #654396)
Cod sursa(job #654396)
/*pascal - info arena
http://infoarena.ro/problema/pascal
*/
#include<cstdio>
using namespace std;
long long r,d,v[5000],i,j;
int f(int x)
{
int nr=1;
for(i=1;i<=x;i++)
{
nr*=i;
}
return nr;
}
void citire()
{
freopen("pascal.in", "r",stdin);
scanf("%d %d", &r,&d);
}
int main()
{
citire();
for (j=1;j<=(r/2)+1;j++)
{
v[j]=f(r)/(f(r-j)*f(j));
}
int tot=0;
for(i=1;i<=(r/2)-1;i++)
if(v[i]%d==0)
tot++;
tot=tot*2;
if(v[r/2]%2==0)
tot++;
freopen("pascal.out","w",stdout);
printf("%d",tot);
}