Cod sursa(job #2620998)

Utilizator petrucioinicaPetru Cioinica petrucioinica Data 30 mai 2020 11:18:38
Problema Factorial Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <fstream>
#include <map>
#include <string>


using namespace std;

int main()
{
    int N,P,nu = -1;
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>P;
    if(P < 0)
        g<<nu;
    else
    {
        N = 0;
        int nrzero = 0;
        while(nrzero < P)
        {
            N+=5;
            int x = N;
            while(x)
            {
                if(x%5 == 0)
                    nrzero++;
                x = x/5; 
            }
        }
        if(nrzero == P)
            g<<N;
        else
        {
            g<<nu;
        }
        
    }

}