Pagini recente » Cod sursa (job #1205879) | Cod sursa (job #333356) | Cod sursa (job #2155966) | Cod sursa (job #808833) | Cod sursa (job #382039)
Cod sursa(job #382039)
#include <fstream>
using namespace std;
int main(){
ifstream fi("fact.in");
ofstream fo("fact.out");
int a[14]={1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125};
int b[14]={0, 1, 6, 31, 156, 781, 3906, 19531, 97656, 488281, 2441406, 12207031, 61035156, 305175781};
int p, i, nr;
fi>>p;
for(i=0;i<=13;i++){
if(p==b[i]){
fo<<a[i];
return 0;
}
if(p<b[i])
break;
}
nr=(p-b[i-1])*5+a[i-1];
fo<<nr;
return 0;
}