Cod sursa(job #538363)

Utilizator dtoniucDaniel Toniuc dtoniuc Data 21 februarie 2011 09:34:20
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]={0,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625,1220703125};
int b[13]={0,6,  31,156, 781, 3906,19531, 97656, 488281,2441406,12207031, 61035156, 305175781};
int main ()
{
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	fin>>p;
	int in=0;
	if (p==0) fout<<"1";
	else 
	{
		while (p>b[in])	in++;
		in-=1;
		fout<<a[in]+(p-b[in])*5;
	}
	return 0;
}