Pagini recente » Atasamentele paginii Infoarena Monthly 2012 - Runda 1, Probleme | Cod sursa (job #3121266) | Cod sursa (job #1827719) | Monitorul de evaluare | Cod sursa (job #1462442)
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main(){
long long n,i,j,s=1,p=-5,h=1,x=0;
in>>n;
if(n==25)
{
out<<"-1";
return 0;
}
long long aux;
aux=n;
aux=aux*5;
if(n==0)
{
out<<"-1";
return 0;
}
for(i=1;i<=100000000;i++)
{
s=s*5;
p=p+5;
h=h+x;
x++;
n=h+x-1;
if(s>aux)
{
out<<aux;
return 0;
}
if(s==n)
{
out<<"-1";
return 0;
}
if(s<aux)
{
aux=aux-p;
}
}
}