Cod sursa(job #2337830)
Utilizator | Data | 6 februarie 2019 18:54:19 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int nr0(int x)
{
int sol=0;
while(x)
{
x/=5;
sol+=x;
}
return sol;
}
int n,poz;
int main()
{
in>>n;
poz=0;
for(int i=(1<<29);i>0;i/=2)
if(nr0(poz+i)<n) poz+=i;
if(nr0(poz+1)==n) out<<poz+1;
else out<<-1;
return 0;
}