Cod sursa(job #1013835)

Utilizator AnduuFMI Alexandru Banu Anduu Data 21 octombrie 2013 19:51:12
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <fstream>
using namespace std;
int p;
void citire ()
{
    ifstream in ("fact.in");
    in >> p;
    in.close ();
}
void afis (long long n)
{
    ofstream out ("fact.out");
    out << n;
    out.close ();
}
void solve ()
{
    if (p == 0)
        afis (1);
    else
        if (p == (p / 5)* 5 + (p / 5 - 1))
            afis (-1);
        else
        {
            int n = p % 5;
            if (n == 0)
                n = 5;
                afis (p * 4 + n);
        }
}
int main()
{
    citire ();
    solve ();
    return 0;
}