Pagini recente » Cod sursa (job #2292740) | Istoria paginii utilizator/anamariaradu | Cod sursa (job #2482945) | Profil mirceadruta | Cod sursa (job #247095)
Cod sursa(job #247095)
#include <iostream.h>
#include <stdio.h>
int main()
{int i;
long p,n=0,v[14],x=0;
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
cin>>p;
if(p==0) {cout<<1; return 0;}
else
{for(i=2;i<14;i++) v[i]=0;
while(x<p)
{n+=25; v[2]+=25; x+=6;
if(v[2]==125) {v[3]+=v[2]; v[2]=0; ++x;}
if(v[3]==625) {v[4]+=v[3]; v[3]=0; ++x;}
if(v[4]==3125) {v[5]+=v[4]; v[4]=0; ++x;}
if(v[5]==15625) {v[6]+=v[5]; v[5]=0; ++x;}
if(v[6]==78125) {v[7]+=v[6]; v[6]=0; ++x;}
if(v[7]==390625) {v[8]+=v[7]; v[7]=0; ++x;}
if(v[8]==1953125) {v[9]+=v[8]; v[8]=0; ++x;}
if(v[9]==9765625) {v[10]+=v[9]+1; v[9]=0; ++x;}
if(v[10]==48828125) {v[11]+=v[10]; v[10]=0; ++x;}
if(v[11]==244140625) {v[12]+=v[11]; v[11]=0; ++x;}
if(v[12]==1220703125) {v[13]+=v[12]; v[12]=0; ++x;}}
if(x==p) cout<<n;
else if(x==p+1) cout<<-1;
else cout<<n-5*(x-p-1);}
fcloseall();
return 0;
}