Cod sursa(job #1028265)

Utilizator corujandariusCorujan Darius corujandarius Data 13 noiembrie 2013 20:21:05
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    long long unsigned p,d=0,c=0,i,i2;
    ifstream fin("fact.in");
    ofstream fout("fact.out");
    fin>>p;
   for(i=1;;i++)
   {
       i2=i;
       //while(i2%2==0)
       //{
         //  d++;
        //   i2=i2/2;
       //}
       while(i2%5==0)
       {
           c++;
           i2=i2/5;
       }
       //if(d==p && d<=c)
       //{
          // fout<<i;
          // break;
       //}else
       if(c==p)
       {
           fout<<i;
           break;
       }
       if(c>100000000)
       {
           fout<<-1;
           break;
       }
   }

    fin.close();
    fout.close();
    return 0;
}