Cod sursa(job #1779348)
| Utilizator | Data | 15 octombrie 2016 10:09:47 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long p,l,k,i;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f >> p;
k=5;
l=1;
if (p==0) cout << 1;
else
if (p==1) cout << 5;
else
for (int i=2;i<=9999999;++i)
{
l=l+1;
if (p==k)
{
cout << -1;
return 0;
}
if (i>k)
{
l=l-1;
k=k+6;
}
if (i==p)
{
l=l*5;
return 0;
}
}
g << l;
return 0;
}
