Pagini recente » Monitorul de evaluare | Niciomare | Cod sursa (job #1575569) | Atasamentele paginii Rezultate Info Oltenia 2018 Proba pe Echipe | Cod sursa (job #2155514)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int x;
int zero( int n ) {
x = 0;
while ( n > 0 ) {
x = x + n/ 5;
n /= 5;
}
return x;
}
int main()
{
int r , pas, g;
in >> g;
if ( g == 0 ) {
out << 1;
return 0;
}
r = 0;
pas = 1 << 25;
while ( pas != 0 ) {
if ( zero(r+pas) <= g ) {
r += pas;
}
pas /= 2;
}
if ( zero(r) == g )
out << r-4;
else
out << "-1";
return 0;
}