Cod sursa(job #1711408)
Utilizator | Data | 31 mai 2016 09:44:30 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int pas=1<<20;
int main()
{
int p,n=0,i=0,x;
in >> p;
x=p+1;
if(!p) out <<0;
else
{
if(x%6==0) out << -1;
else
{
while(pas)
{
if(i+pas<=5*p)
i+=pas;
pas/=2;
}
out << i;
}
}
return 0;
}