Pagini recente » Cod sursa (job #2099610) | Cod sursa (job #1973059) | Cod sursa (job #2807016) | Cod sursa (job #787478) | Cod sursa (job #654390)
Cod sursa(job #654390)
/*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)
{
if (x==0)
return 1;
else return f(x-1)*x;
}
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);
}