Cod sursa(job #1094326)
Utilizator | Data | 29 ianuarie 2014 11:33:31 | |
---|---|---|---|
Problema | Factorial | Scor | 85 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int n)
{
int nr=0;
while(n>=5)
{
nr+=n/5;
n/=5;
}
return nr;
}
int cautb(int p)
{
int i=0,pas=1<<30;
while(pas!=0)
{
if(zero(i+pas)<p)
i+=pas;
pas/=2;
}
if(i!=0)
return i+1;
else
return -1;
}
int main()
{
int p;
in>>p;
out<<cautb(p);
return 0;
}