Cod sursa(job #1779337)
Utilizator | Data | 15 octombrie 2016 09:41:17 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long n,nr=0,x,y;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>n;
x=n*5;
while (nr!=n)
{
nr=0;
for (int i=5;i<=x;i+=5)
{
y=i;
while (y%5==0)
{
nr++;
y=y/5;
}
}
if (nr>n) x=x-5;
else if (nr==n) {g<<x; return 0;}
else {g<<-1; return 0;}
}
return 0;
}