Cod sursa(job #1418551)
Utilizator | Data | 13 aprilie 2015 14:11:30 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long P;
int main()
{
int k=0,i,x=0;
f>>P;
f.close();
if (P%10 == 5) g<<-1<<'\n';
else if (P==0) g<<1<<'\n';
else
{for (i = 1;i <= P; i+=5)
{
k+=20+x;
x+=5;
}
g<<k-5*(i-P-1)<<'\n';
}
}