Cod sursa(job #1711539)

Utilizator DaniellDa Vinci Daniell Data 31 mai 2016 16:37:41
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>

using namespace std;

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

int p;

int desc(int h,int k)
{
    h/=5;
    if(!((h/5)%5)) return 1+desc(h,k);
    return 1;
 }

int rez(int h,int k)
{
    h+=5;k++;
    if(!((h/5)%5))
        k+=desc(h,k);
    if(k<p)
    return rez(h,k);
    if(k==p)
    return h;
    return -1;

    }


void read()
{fin>>p;
if(p==0)fout<<1;
else
    fout<<rez(5,1);
}

int main()
{
read();
    return 0;
}