Cod sursa(job #1346283)

Utilizator tudor_bonifateTudor Bonifate tudor_bonifate Data 18 februarie 2015 09:45:53
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <iostream>
#include <fstream>
using namespace std;
int p,i,x,nr,pr;
bool OK;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
    f>>p;
    if (p<0) g<<"-1";
    else
    {
        OK=true;
        i=1;
        while (OK==true)
        {
            x=i;
            pr=5;
            nr=0;
            while (pr<=x)
            {
                nr=nr+x/pr;
                pr*=5;
            }
            if (nr==p)
            {
                g<<i;
                OK=false;
            }
            i++;
        }
    }
    return 0;
}