Cod sursa(job #2251692)

Utilizator NymeriaMurariu Alexandra Nymeria Data 1 octombrie 2018 20:56:20
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p;

int cautare(int p)
{
    int x = 5, nr5 = 0, doppel;
    if(p == 0)
        return 1;
    else {
            do {
                doppel = x;
                while(doppel % 5 == 0) {
                    doppel = doppel / 5;
                    nr5++;
                }
                if(nr5 == p)
                    break;
            x = x + 5;
        } while(nr5 < p);
    }
    if(nr5 == p)
        return x;
    else
        return -1;
}


int main()
{
    f >> p;
    g << cautare(p);
    return 0;
}