Pagini recente » Cod sursa (job #518733) | Cod sursa (job #1027041) | Cod sursa (job #80889) | 4 | Cod sursa (job #3173118)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main(){
int P,N=0,i,fact,c;
fin >> P;
bool gasit = false;
while(!gasit){
N++;
c=0;
for(i=1;i<=N;i++)
{
if(i%2==0 && i%5==0)
{
while(i%2==0 && i%5==0){
c++;
if(i%2==0)
i/=2;
else
if(i%5==0)
i/=5;
}
}
}
if(c==P)
gasit = true;
else
if(c>P)
gasit = true;
}
if(c==P)
fout << N;
else
fout << "-1";
return 0;
}