Pagini recente » Cod sursa (job #2955009) | Cod sursa (job #54925) | Cod sursa (job #337104) | Cod sursa (job #571557) | Cod sursa (job #3174795)
#include <iostream>
#include <cmath>
#include <fstream>
std::ifstream fin("fact.in");
std::ofstream fout("fact.out");
unsigned long long Binary_Exp(unsigned long long a, unsigned long long b) {
unsigned long long thing = 1;
while (b>0){
if (b&1) {thing*=a;}
a*=a;
b >>=1;
}
return thing;
}
unsigned int Zero_La_Final_Fact(unsigned int n) {
if (n<5) {
return 0;
}
unsigned int s=0,p=1;
while (std::floor(n/Binary_Exp(5,p))>0){
s+=std::floor(n/Binary_Exp(5,p));
p++;
}
return s;
}
int main()
{
unsigned int p;
fin >> p;
unsigned int Q=1;
while(Zero_La_Final_Fact(Q)<p) {
Q++;
}
fout << Q;
return 0;
}