Cod sursa(job #1923634)
| Utilizator | Data | 11 martie 2017 19:47:17 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
long long sum[100000001],P,S2,S=1;
const long long N=1<<50;
int caut()
{
long long pas=N;
int r=0;
while(pas!=0)
{
if(pas+r<=5*P && sum[pas+r]<=P)
r+=pas;
pas/=2;
}
return r;
}
int main()
{
int n=0,i=1;
in>>P;
sum[0]=1;
if(P==0)
out<<sum[P];
else{
while(i<=5*P)
{
S=S*i;
if(S%10==0)
{
n++;
S/=10;
}
sum[i]=n;
i++;
}
out<<caut();
}
return 0;
}
