Cod sursa(job #1462438)
Utilizator | Data | 18 iulie 2015 02:31:50 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main(){
long long n,i,j,s=1,p=-5;
in>>n;
n=n*5;
for(i=1;i<=100000000;i++)
{
s=s*5;
p=p+5;
if(s<n)
{
if(s!=5)
n=n-p;
}
if(s==n)
{
out<<"-1";
return 0;
}
if(s>=n)
{
out<<n;
return 0;
}
}
}