Cod sursa(job #2378580)

Utilizator victorv88Veltan Victor victorv88 Data 12 martie 2019 13:57:15
Problema Factorial Scor 25
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=5, 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+=5;
        }
    }
    return 0;
}