Cod sursa(job #2072520)

Utilizator Andrei_RAndrei Roceanu Andrei_R Data 21 noiembrie 2017 22:07:21
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int main()
{
    int p, i, n, cn;
    f >> p;
    n = 0;
    for ( i = 0; i < p; i++ ) {
        n += 5;
        cn = n/5;
        while ( cn % 5 == 0 ) {
            i++;
            cn /= 5;
        }
    }
    if ( n == 0 )
        g << "1";
    else
        g << n;
    return 0;
}