Pagini recente » Cod sursa (job #2355003) | Cod sursa (job #2591925) | Cod sursa (job #2038140) | Cod sursa (job #1591546) | Cod sursa (job #446913)
Cod sursa(job #446913)
#include<fstream.h>
#include<math.h>
long long c[13],ok[13];
int main ()
{
ifstream fcin("fact.in");
ofstream fcout("fact.out");
long long k,i,s=0,j;
fcin>>k;
while(k>155)
{i=1;
c[i]=c[i]+125;i++;c[i]=c[i]+25;i++;c[i]=c[i]+5;k=k-155;
while(c[i]%5==0)if(k>0)
{i++;c[i]++;k--;}}
while(k>0)
{i=1;
c[i]++;k--;
while(c[i]%5==0){i++;c[i]++;k--;}}
if(k==0&&c[1]>0)fcout<<c[1]*5<<'\n';
else if(c[1]==0)fcout<<1<<'\n';
else fcout<<-1<<'\n';
return 0;
}