Cod sursa(job #1107048)

Utilizator terrorturtle01Ion George Mihai terrorturtle01 Data 13 februarie 2014 16:42:22
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
using namespace std;
int P, nrz = 1, N = 1, n;

int zero(int k){
    int m = 5, z = 0;
    while(k/m != 0){
        z+=k/m;
        m*=5;
    }
    return z;
}

int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>P;
    while(nrz < P){
        if(P == 0){
            g<<1;
        }
        nrz = zero(N);
        N++;
    }
    g<<N-1;
    return 0;
}