Cod sursa(job #1905130)

Utilizator StefanUrsacheStefan Ursache StefanUrsache Data 5 martie 2017 22:08:12
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p, n, x;
int main()
{
    f>>p;
    if(p==0)
        g<<1;
    else {
        n=5;
        while(p>0) {
            x=n;
            while(x%5==0) {
                p--;
                x/=5;
            }
            n+=5;
        }
        if(p==0)
            g<<n-5;
        else
            g<<-1;
    }
    g<<'\n';
    f.close();
    g.close();
    return 0;
}