Cod sursa(job #2209528)

Utilizator alexcmoteaalexcmotea alexcmotea Data 3 iunie 2018 18:44:40
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>

using namespace std;
int pow5(int x)
{
    int cnt=0;
    while(x>0)
    {
        cnt+=x/5;
        x=x/5;
    }
    return cnt;
}
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
    int n,x=0,pas;
    in>>n;
    while(pas)
    {
        if(pow5(x+pas)<n)
            x=x+pas;
        pas=pas/2;
    }
    if(pow5(x+1)==n)
        out<<x+1;
    else
        out<<"-1";
    return 0;
}