Cod sursa(job #161331)

Utilizator lache92Hulub Ionut-Adrian lache92 Data 17 martie 2008 21:34:27
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream.h>

int main() {
    long int p;
    ifstream f("fact.in");
    ofstream fout("fact.out");
    f>>p;
    if (p == 0) {
       fout<<1;
       return 0;
       }
    if (p%5 == 0) {
            fout<<-1;
            return 0;
            }
    fout<<(p * 5) - ((p/6)*5) - ((p/1000)*5) - ((p/10000)*5) - ((p/100000)*5) - ((p/1000000)*5) - ((p/10000000)*5) - ((p/100000000)*5);
    return 0;
}