Cod sursa(job #2378578)

Utilizator victorv88Veltan Victor victorv88 Data 12 martie 2019 13:55:52
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <cstdio>
#include <stdlib.h>
using namespace std;

int p, x=1, nr,aux;

int main()
{
    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);
    cin >> p;
    if (p==0)
        cout << 1;
    else{
        while (p)
        {
            aux=x;
            while (!(aux%10) && p)
            {
                aux/=10;
                --p;
            }
            while (!(aux%5) && p)
            {
                aux/=5;
                --p;
            }
            if (p==0)
            {
                cout << x << '\n';
            }
            ++x;
        }
    }
    return 0;
}