Cod sursa(job #1325765)

Utilizator beatrice01Ferco Beatrice beatrice01 Data 24 ianuarie 2015 12:44:14
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>

using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,k=1,n=5,r,cp;
int main()
{
    f>>p;
    if(p==0) g<<"1";
    else
    {
       while(p>0)
        { n=5*k;
        cp=n;
        r=0;
        while(cp>1)
        {
        if(cp%5==0){r++;cp/=5;}
        else cp=1;

        }

        p=p-r;

        k++;
      }

      g<<n;
    }
    return 0;
}