Pagini recente » Cod sursa (job #1155661) | Cod sursa (job #2576376) | Cod sursa (job #2571928) | Cod sursa (job #43558) | Cod sursa (job #793278)
Cod sursa(job #793278)
#include <fstream>
#include <iostream>
using namespace std;
int s = 1, d = 100000000, m, p, k, j;
int functie ( int x )
{
k =0;
j = 5;
while ( j < x )
{
k += x/j;
j *= 5;
}
return k;
}
int main ( void )
{
ifstream fin ( "fact.in" );
ofstream fout ( "fact.out" );
fin >> p;
while ( s < d )
{
int x = functie ( ( s + d ) / 2 );
if ( x >= p )
d = ( s + d ) / 2;
if ( x < p )
s = ( s + d ) / 2 + 1;
}
fout << s;
fin.close();
fout.close();
}