Cod sursa(job #2078450)
Utilizator | Data | 29 noiembrie 2017 16:39:52 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int nr_0 (int x)
{
int 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");
int P,pas=1<<30,r=0;
fin>>P;
while(pas!=0)
{
if(nr_0(r+pas)<P)
r+=pas;
pas/=2;
}
fout<<r+1;
return 0;
}