Cod sursa(job #3141287)
Utilizator | Mocan Radu radu1331 | Data | 13 iulie 2023 14:27:49 |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll nr_cinci (ll n)
{
ll num = 0 ;
while ( n )
{
num += n / 5 ;
n /= 5 ;
}
return num;
}
const int MAX = 1e17 ;
int main ( )
{
freopen ( "fact.in" , "r" , stdin ) ;
freopen ( "fact.out" , "w" , stdout ) ;
ll p ; cin >> p ;
ll index = 0 ;
for ( int bit = 17 ; bit >= 0 ; bit -- )
{
index += ( 1 << bit ) ;
if ( nr_cinci ( index ) > p - 1 ) index -= ( 1 << bit ) ;
}
cout << index + 1 ;
return 0 ;
}