Nu aveti permisiuni pentru a descarca fisierul grader_test27.ok
Cod sursa(job #1428079)
Utilizator | Data | 3 mai 2015 17:32:23 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long Zerouri(long long a)
{
long long z = 0;
for( long long i = 5; i <= a; i *= 5 )
z += a / i;
return z;
}
int main()
{
long long Infi = 1 << 30, p;
fin >> p;
long long step = Infi, ans;
for(ans = Infi; step; step >>= 1 )
if( ans - step > 0 && Zerouri(ans - step) >= p )
ans -= step;
if( ans == Infi || Zerouri(ans) != p )
fout << -1;
else
fout << ans;
return 0;
}