Cod sursa(job #1687055)
Utilizator | Data | 12 aprilie 2016 17:28:44 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int zero(int x)
{
int p5 = 5;
int d = 0;
while (x/p5 != 0) {
d =d+ (x/p5);
p5=p5*5;
}
return d;
}
int P;
int main()
{
int N=0,P,i=1;
cin>>P;
while(N==0)
{
if(zero(i)==P)
{
N=i;
}
if(zero(i)>P)
{
N=-1;
}
i++;
}
cout<<N;
}