Cod sursa(job #1961363)
Utilizator | Data | 11 aprilie 2017 08:24:49 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
int nr,x,n,p;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
n=5;
if (p==0) g<<1;
else
while (1)
{
x=n;
while (x%5==0)
{
x=x/5;
nr++;
}
if (nr==p) {g<<n; break;}
else if (nr>p) {g<<-1; break;}
n=n+5;
}
return 0;
}