Cod sursa(job #1191698)
Utilizator | Data | 28 mai 2014 14:39:05 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.09 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main ()
{
int p,k,aux,aux2=0,plm;
f>>p;
aux=1;
k=5;
plm=0;
if(p==0)
g<<1;
else
while(aux2==0)
{
if(p==k)
{
aux2=1;
g<<-1;}
else
{
if(p>k)
{
if(aux<5)
{aux=aux+1;
k=k+6;
plm=plm+1;}
else
{
aux=1;
if(k==29)
{k=k+1;
plm=plm+1;
}
}
}
else
{
p=p-plm;
g<<p*5;
aux2=1;
}
}
}
f.close();
g.close();
return 0;
}