Cod sursa(job #1923590)
| Utilizator | Data | 11 martie 2017 17:38:18 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
long long sum[10001],P,S2,S=1;
const int N=1<<25;
int caut()
{
int pas=N,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;
}
