Cod sursa(job #1069354)
Utilizator | Data | 29 decembrie 2013 20:56:44 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.3 kb |
#include <fstream>
using namespace std;
int main(){
fstream fin("fact.in",ios::in), fout("fact.out", ios::out);
long p,x;
fin>>p;
if(p==0) fout<<"1";
x=p-(31*(p/31));
if((x-5)%6==0) fout<<"-1";
if((p+1)%31==0) fout<<"-1";
if((p!=0)&&((p+1)%31!=0)&&((x-5)%6!=0)) fout<<p*5-5*(p/6+p/31);
return 0;
}