Cod sursa(job #2394431)
Utilizator | Data | 1 aprilie 2019 16:58:05 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("fact.in");
ofstream out("fact.out");
unsigned p, nraux=5, nr5=1;
in>>p;
while(nr5<p)
{
nraux+=5;
unsigned aux =nraux;
while (aux%5==0)
{
nr5+=1;
aux/=5;
}
}
if(nr5==p)
out<<nraux;
else
out<<"-1";
return 0;
}