Pagini recente » Cod sursa (job #2463928) | Cod sursa (job #940824) | Istoria paginii runda/pogo.danseaza | 225200 | Cod sursa (job #997980)
Cod sursa(job #997980)
#include<fstream>
using namespace std;
ifstream f("pascal.in");
ofstream g("pascal.out");
int R,D,m,v[10],sol;
void Descompunere(int x, int y)
{
while(x % 2==0)x/=2,v[2]++;
while(x % 3==0)x/=3,v[3]++;
while(x % 5==0)x/=5,v[5]++;
while(y % 2==0)y/=2,v[2]--;
while(y % 3==0)y/=3,v[3]--;
while(y % 5==0)y/=5,v[5]--;
}
int Div()
{
if(D==4 && v[2]>1)return 1;
if(D==6 && v[2]>0 && v[3]>0)return 1;
if(v[D]>0)return 1;
return 0;
}
int main()
{
f>>R>>D;
m=R;
for(int i=1;i<=m/2;i++,R--)
{
Descompunere(R,i);
if(Div())sol+=2;
}
if(m % 2==0 && Div())sol--;
g<<sol<<"\n";
f.close();g.close();
return 0;
}