Pagini recente » Cod sursa (job #2183377) | Cod sursa (job #451070) | Cod sursa (job #408476) | Cod sursa (job #1374634) | Cod sursa (job #127245)
Cod sursa(job #127245)
#include <fstream.h>
#include <iostream.h>
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
long p,n2,c,b,b2=0,n=0,ct=1;
// cin>>p;
fin>>p;
while (p>=1)
{
n2=1;c=1;b=1;
while (n2<=p)
{
c=n2;
b=b*5;
n2=b+c;
}
n=n+b;
if (b2==b)
{
ct=ct+1;
if (ct==5) n=-1;
}
else ct=1;
b2=b;
p=p-c;
cout<<c<<endl;
}
if (!n) n=1;
// cout<<n;
fout<<n;
return 0;
}