Cod sursa(job #1449493)

Utilizator butiriButiri Alexandru Dan butiri Data 9 iunie 2015 20:05:49
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    fstream file;
    unsigned int p, n;

    file.open("fact.in", ios::in);
    file >> p;
    file.close();

    file.open("fact.out", ios::out);

    if(p == 0) {
        file << 1 << endl;
    } else {
        n = (p - p / 5) * 5;

        if(!((p - p / 5 + 1) % 5)) {
            file << -1 << endl;
        } else {
            file << n << endl;
        }
    }

    file.close();

    return 0;
}