Cod sursa(job #1449483)

Utilizator butiriButiri Alexandru Dan butiri Data 9 iunie 2015 18:52:54
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>

using namespace std;

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

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

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

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

    file.close();

    return 0;
}