Cod sursa(job #538347)
| Utilizator | Data | 21 februarie 2011 08:53:36 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int p,n;
int a[13]={25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625,1220703125};
int b[13]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int main ()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
fin>>p;
if (p==0) fout<<"1";
else
{
int i=11;
n=p*5;
while (n<a[i])
i--;
n-=b[i]*5;
fout<<n;
}
return 0;
}