Cod sursa(job #446146)
Utilizator | Data | 25 aprilie 2010 11:24:29 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include<fstream.h>
#include<math.h>
long long c[13];
int main ()
{
ifstream fcin("fact.in");
ofstream fcout("fact.out");
long long k,i,s=0;
fcin>>k;
while(k>0)
{i=1;
c[i]++;k--;
if(k>0)while(c[i]%4==0){c[i+1]++;i++;k=k-i;}}
for(i=1;i<=12;i++)
s=s+c[i];
if(k==0&&s>0)fcout<<s*5;
else if(s==0)fcout<<1;
else fcout<<-1;
return 0;
}