Cod sursa(job #1075566)
Utilizator | Data | 9 ianuarie 2014 10:49:06 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long nrz(long long x){
long long s=0;
while(x>4){
s=s+x/5;
x=x/5;
}
return s;
}
int main()
{
long long i=0,pas=1<<20,n;
f>>n;
while(pas!=0){
if(nrz(i+pas)<n)
i+=pas;
pas/=2;
}
if(nrz(i+1)==n)
g<<i+1;
else
g<<"-1";
return 0;
}