Cod sursa(job #2203973)

Utilizator dorinm17Manea Dorin dorinm17 Data 13 mai 2018 21:41:50
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    int p, n=0, ct=0, x;
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>p;
    while(true)
    {
        if(p==0)
        {
            g<<1;
            break;
        }
        n+=5;
        x=n;
        while(true)
            if(x%5==0)
            {
                ct++;
                x/=5;
            }
            else
               break;
        if(ct==p)
        {
            g<<n;
            break;
        }
        if(ct>p)
        {
            g<<-1;
            break;
        }
    }
    f.close();
    g.close();
}