Cod sursa(job #3121316)
Utilizator | Data | 11 aprilie 2023 19:34:45 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fisin("fact.in");
ofstream fisout("fact.out");
int main()
{
int P,x;
int j=0;
fisin>>P;
if(P==0)
{
fisout<<-1;
return 0;
}
while (x<P || x!=P)
{
x=0;
j++;int y=j;
while(y!=0)
{
x += y/5;
y=y/5;
}
}
if(x>P)
{
fisout<<-1;
}
else
{
fisout<<j;
}
}