Cod sursa(job #1751250)

Utilizator fulger13Pomirleanu Sebastian fulger13 Data 1 septembrie 2016 00:00:13
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream q("factorial.in");
wfstream w("factorial.out");

int main()
{int p,n,s=0;
    q>>p;
    if(p<0) {w<<"-1"; return 0;}
    if(p==0) {w<<"1"; return 0;}
    for(n=5;s<p;n+=5)
    {
        int x=n;
        while(x)
        {
            if(x%5==0) s++;
            x/=5;
        }
    }
    if(s==p) w<<n-5;
    else w<<"-1";

    return 0;
}