Cod sursa(job #3141924)

Utilizator David0911David Teregovan David0911 Data 17 iulie 2023 18:27:50
Problema Factorial Scor 55
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int  p, c, a;
void div(int x)
{

    while(x % 5 == 0)
    {
        c++;
        x/= 5;
    }

}
int main()
{
    fin >> p;
    int nr = 0, i = 1;
    a = 1;
    while(nr < p)
    {   c = 0;
        a = a * i;
        int d = i;
        if(i % 5 == 0)
            div(d);
        nr+= c;
        i++;

    }
    if(nr == p)
        fout << i - 1;
    else
        fout << -1;
    return 0;
}