Cod sursa(job #892118)

Utilizator margikiMargeloiu Andrei margiki Data 25 februarie 2013 22:22:55
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
    int k,p,n,pow;
    f>>p;
    n=4*p+5;
    do {
        pow = 5;
        k = 0;
        while(n/pow) {
                        k += n/pow;
                        pow *= 5;
                     }
        n += 5;
    } while(k < p);
    n -= 5;
    if(p == 0) g<<1;
    else if(k == p) g<<n<<"\n";
         else g<<-1;

    return 0;
}