Cod sursa(job #1548779)

Utilizator DavidLDavid Lauran DavidL Data 11 decembrie 2015 15:18:51
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<fstream>
using namespace std;

int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    int p,n=-1,b=0;
    f>>p;
    while (n==-1)
    {
        b++;
        int f2=0,f5=0,zece;
        for (int j=2; j<=b; j++)
        {
            int aux=j;
            while (aux%5==0&&f5<p)
            {
                f5++;
                aux/=5;
            }
            aux=j;
            while (aux%2==0&&f2<p)
            {
                f2++;
                aux/=2;
            }
        }
        if (f2>=p&&f5>=p&&(f2==p||f5==p)) n=b;
    }
    g<<n;
}