Cod sursa(job #476791)
| Utilizator | Data | 12 august 2010 13:11:58 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 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++) {
#endif
out<<"("<<p<<") -> ";
if (p == 0) out<<1;
else if ((p+1) % 6 == 0 || (p%30 == 0)) out<<-1<<endl;
else out<<fact(p)<<endl;
#if DEBUG == 1
}
#endif
out.close();
return 0;
}
