Cod sursa(job #1204761)
| Utilizator | Data | 3 iulie 2014 21:23:47 | |
|---|---|---|---|
| Problema | Factorial | Scor | 55 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<fstream>
#define InFile "fact.in"
#define OutFile "fact.out"
using namespace std;
long long p;
unsigned long long nr;
unsigned short v[1000],i;
int main()
{
ifstream fin(InFile);
ofstream fout(OutFile);
fin>>p;
do
{
nr+=5;v[1]++;i=1;--p;
while(v[i])
if(v[i]==5){v[i]=0;v[++i]++;--p;}else break;
}while(p>0);
if(p<0)fout<<-1;
else fout<<nr;
return 0;
}
