Cod sursa(job #654677)

Utilizator adrian6Adrian Berteanu adrian6 Data 30 decembrie 2011 19:28:17
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
    int P,N=0,nr=0,i,k,p=1;
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>P;
    for(k=1;k<=10*P;k++)
    {
    for(i=1;i<=k;i++)
    {
        p=p*i;
    while(p!=0)
    {
      if(p%10==0)
      {nr=nr+1;
      p=p/10;}
      else {cout<<nr;break;}
     }
    }
     if(nr==P)
     {
         N=k;
         g<<N;
         break;
     }
     }
     if(N==0)
     {N=-1;
      g<<N;}
 g.close();
 return 0;
}