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