Cod sursa(job #476805)
| Utilizator | Data | 12 august 2010 13:19:26 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#define DEBUG 0
#include<fstream>
using namespace std;
inline int fact(int zeros)
{
return (zeros - (zeros/6) - (zeros/30))*5;
}
int main()
{
int p;
ifstream in ("fact.in");
ofstream out ("fact.out");
in>>p;
#if DEBUG == 1
for (p = 0; p < 100; p++) {
out<<"("<<p<<") -> ";
#endif
if (p == 0) out<<1;
else if (((p+1) % 6 == 0) || (p%30 == 0)) out<<-1;
else out<<fact(p);
#if DEBUG == 1
out<<endl;
}
#endif
out.close();
return 0;
}
