Pagini recente » Cod sursa (job #2896749) | Cod sursa (job #1017196) | Cod sursa (job #1703535) | Cod sursa (job #2030933) | Cod sursa (job #1821625)
#include <fstream>
using namespace std;
int n,d,c=0,x2=0,x3=0,x5=0;
void adun()
{
if (d==2 && x2>0) c++;
if (d==3 && x3>0) c++;
if (d==4 && x2>1) c++;
if (d==5 && x5>0) c++;
if (d==6 && x2>0 && x3>0) c++;
}
void calc()
{
//for (int x,i=1; i<=n; i++)
for (int x,i=1; i<=n/2; i++)
{
x=n-i+1;
while (x % 2 == 0)
{
x2++;
x/=2;
}
while (x % 3 == 0)
{
x3++;
x/=3;
}
while (x % 5 == 0)
{
x5++;
x/=5;
}
x=i;
while (x % 2 == 0)
{
x2--;
x/=2;
}
while (x % 3 == 0)
{
x3--;
x/=3;
}
while (x % 5 == 0)
{
x5--;
x/=5;
}
adun(); if ((n % 2==1) || (i!=n/2 && n % 2== 0)) adun();
}
}
main()
{
ifstream fin("pascal.in");
fin >> n >> d;
fin.close();
calc();
ofstream fout("pascal.out");
fout << c;
fout.close();
}