Mai intai trebuie sa te autentifici.
Cod sursa(job #1424853)
Utilizator | Data | 25 aprilie 2015 16:15:38 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fi("fact.in");
ofstream fo("fact.out");
int zero(int n){
int nr=0;
while(n>=5)
{
nr+=n/5;
n/=5;
}
return nr;
}
int cb(int p){
int i=0, pas=1<<30;
while(pas!=0){
if(zero(i+pas)<p)
i+=pas;
pas/=2;
}
return 1+i;
}
int main()
{
int nr,s;
fi>>nr;
s=cb(nr);
if(zero(s)==nr)
fo<<s;
else
fo<<"-1";
return 0;
}