Cod sursa(job #2257075)

Utilizator RobertuRobert Udrea Robertu Data 9 octombrie 2018 16:42:21
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int main()
{
    int P, n, s, cnt;

    in >> P;

    for(n = 1; n <=100; n++)
    {s = 1;
     cnt = 0;
        for(int j = 1; j <= n; j++)
        {
            s = s * j;
        }

        while(s % 10 == 0)
        {
             cnt++;

            s = s / 10;
        }

        if( cnt == P)
        {
            out<<n;
            break;
        }
    }

    return 0;
}