Cod sursa(job #729271)

Utilizator andreistb1996Satirbasa Andrei andreistb1996 Data 29 martie 2012 14:03:00
Problema Pascal Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include<fstream>
using namespace std;
ifstream f("pascal.in");
ofstream g("pascal.out");
int k,i,r,n,d,nr,x,v[6];
int main()
{f>>r>>d;
n=r;
k=r/2;
for(i=1;i<=k;i++,n--)
{	x=n;
while(x%2==0)
{x=x/2;
v[2]++;}
while(x%3==0)
{x=x/3;
v[3]++;}
while(x%5==0)
{x=x/5;
v[5]--;}
x=i;
while(x%2==0)
{x=x/2;
v[2]--;}
while(x%3==0)
{x=x/3;
v[3]--;}
while(x%5==0)
{x=x/5;
v[5]--;}
if((d==6 && v[2]>0 && v[3]>0)||(d==4 && v[2]>1)||v[d]>0)
nr=nr+2;}
if(((d==6 && v[2]>0 && v[3]>0)||(d==4 && v[2]>1)||v[d]>0) && r%2==0)
nr--;
g<<nr<<'\n';
f.close();
g.close();
return 0;}