Pagini recente » Cod sursa (job #1032979) | Cod sursa (job #1155764) | Cod sursa (job #2846885) | Solutiile oficiale pentru Concursul "de incalzire" | Cod sursa (job #1734531)
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p,n,i;
int putere5(int n)
{
int k=0;
while((pow(5,k))<n)
{
k=k+1;
}
if(k<2)
return 0;
else
return k;
}
int scadere(int p)
{
int aux,y,x,k=1;
x=6;
y=5;
while(x+y<p)
{
y=y+x;
k++;
}
if(x+y==p||p==5)
return 0;
else
return k;
}
int main()
{
fin>>p;
if(p==0)
fout<<1;
else if(p==1)
fout<<5;
else
{
n=p*5;
if(scadere(p)==0)
fout<<-1;
else
fout<<n-(5*(scadere(p)));
}
fin.close();
fout.close();
return 0;
}