Cod sursa(job #793281)
Utilizator | Data | 2 octombrie 2012 14:06:23 | |
---|---|---|---|
Problema | Factorial | Scor | 85 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
#include <iostream>
using namespace std;
long long s = 1, d = (1LL << 60), m, p, k, j;
long long functie ( long long 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 )
{
long long 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();
}