Pagini recente » Cod sursa (job #1943129) | Rating Checiches Andrei Robert (ChecichesAndrei) | Cod sursa (job #872768) | Cod sursa (job #504331) | Cod sursa (job #2078453)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int nr_0 (long long x)
{
long long a=5,y,p=0;
while(a<=x)
{
p+=x/a;
a*=5;
}
return p;
}
int main()
{
ifstream fin("fact.in") ;
ofstream fout("fact.out");
long long P,pas=1<<32,r=0;
fin>>P;
while(pas!=0)
{
if(nr_0(r+pas)<P)
r+=pas;
pas/=2;
}
fout<<r+1;
return 0;
}