Cod sursa(job #2080340)
| Utilizator | Data | 2 decembrie 2017 20:09:27 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <cstdio>
#define NR 100000000
using namespace std;
int p;
int zero(int x)
{
int s=0;
while(x/5!=0)
{
s+=x/5;
x/=5;
}
return s;
}
int cautbin(int lg,int p)
{
int i;
for(i=NR;lg!=0;lg>>=1)
{
if(i-lg>0 && zero(i-lg)>=p)
i-=lg;
}
return i;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
printf("%d",cautbin(134217728,p));
return 0;
}
