Cod sursa(job #6170)
Utilizator | Data | 17 ianuarie 2007 22:29:29 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.33 kb |
#include<fstream.h>
#define input "fact.in"
#define output "fact.out"
int main()
{
long h,x;
int n,k,gr=0;
ifstream fin(input);
ofstream fout(output);
fin>>n;
x=n;
h=1;
while(h*5+1<n)
{
h=(h*5)+1;
gr++;
}
while(gr>0)
{
x-=(n/h);
gr--;
h--;
h=h/5;
}
fout<<x*5;
return 0;
}