Cod sursa(job #483513)

Utilizator cosmyoPaunel Cosmin cosmyo Data 8 septembrie 2010 23:24:44
Problema Pascal Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include<fstream.h>
long k,p,n,d;
long long nr,x[10];
long t[3]={2,3,5};
int main()
{ifstream fin("pascal.in");
  fin>>n>>d;
 fin.close();
ofstream fout("pascal.out");
  
 for(long i=1;i<=n-1;++i)
 {k=0;
  p=i;
	   while(p>1&&k<=2)
	   { while(p%t[k]==0)
		   {--x[t[k]];p/=t[k];}
		++k;
	   }
  k=0;
  p=n-i+1;
	   while(p>1&&k<=2)
	   { while(p%t[k]==0)
		   {++x[t[k]];p/=t[k];}
		++k;
	   }
  if(d==2||d==5||d==5)
	  if(x[d]>0)
		++nr; 
  if(d==4)
    if(x[2]>1)
      ++nr;
	 if(d==6)
		if(x[2]>0&&x[3]>0)
		 ++nr;
  }
 fout<<nr<<'\n';
fout.close();
return 0;
}