Cod sursa(job #2066204)

Utilizator mirunaFmiruna mirunaF Data 14 noiembrie 2017 19:34:04
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <iostream>
#include <fstream>

using namespace std;

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

long long sum[1001],P,S=1,n,s;
const long long N=1<<20;

int caut( )
{
    int r=0;
    long long pas=N;
    while(pas!=0)
    {
        if(r+pas<=

           in && sum[pas+r]<P)
            r+=pas;
        pas/=2;
    }
    if(sum[r+1]==P)
        return r+1;
    return -1;
}

int main()
{
    int i=1,nr=0,j;
    in>>P;
    sum[0]=1;
    n++;
    while(i<=P*P)
    {
        nr=0;
        j=1;
        while(j>0 && j%5==0)
        {
            nr++;
            j/=5;
        }

        sum[i]=nr;
        n++;
        i++;
    }
    out<<caut();
    return 0;
}