Cod sursa(job #1500905)

Utilizator tiberiu1995Arsene Constantin-Tiberiu tiberiu1995 Data 12 octombrie 2015 21:01:07
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");

int main()
{   int P,x,aux; f>>P;
    if(P<0) g<<-1;
    else
    if(P==0) g<<1<<endl;
    else
        {   x=5; P--;
            while(P>0)
            {   aux=x;
                while(aux%5==0&&P>0) {aux/=5; P--;}
            x=x+5;
            }

        }
    g<<x<<endl;
    return 0;
}