Cod sursa(job #1587889)
Utilizator | Data | 2 februarie 2016 17:29:56 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include<fstream>
using namespace std;
int main()
{
ifstream fin ("fact.in");
ofstream fout("fact.out");
int n,p,x,y;
fin>>p;
for(n=1;n++;)
{
x=0;
y=5;
while(y<=n)
{
x=x+(n/y);
y=y*5;
}
if(x==p)
{fout<<n;
return 0;
}
}
fout<<"-1";
fin.close();
fout.close();
}