Cod sursa(job #2336202)
| Utilizator | Data | 4 februarie 2019 21:31:21 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <fstream>
#include <cmath>
using namespace std;
unsigned long long log5(unsigned long long n)
{
int l=0;
while(n%5==0)
{
n/=5;
l++;
}
return l;
}
long long powe(int x,int y)
{
int i=0,p=1;
for(i=1;i<=y;++i)
{
p*=x;
}
return p;
}
ifstream cin("fact.in");
ofstream cout("fact.out");
int main()
{
unsigned long long sg,c5,p,i,c=0;
cin>>p;
if(p==0){
cout<<1;
return 0;}
c5=log5(p);
sg=p-(c5*(c5+1)/2);
cout<<sg*5;
return 0;
}
