Cod sursa(job #1289666)

Utilizator wGEORGEWGeorge Cioti wGEORGEW Data 10 decembrie 2014 09:05:22
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    int p ,x=0 ,a ,c=1;
    f>>p;
    if(p==0)
        g<<"1";
    else{
    while(p!=0&&c==1)
    {
        x+=5;
        a=x;
        while(a%5==0)
        {
            p--;
            a/=5;
        }
        if(p<0)
        {
            g<<"-1";
            c=0;
            break;
        }
    }
    if(c==1)
    g<<x;}
    return 0;
}