Cod sursa(job #2609217)

Utilizator contentqlcontent Qlt contentql Data 2 mai 2020 12:34:15
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda igorj_mentorat1 Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <string.h>
#define PMAX (1<<30)
#define KMAX 1000005
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nr,numar[KMAX],n;
int main()
{
    fin>>n;
    numar[1]=1;
    int k=1,x=2;
    while(nr<n)
    {
        int temp=0,aux,ok=1;
        nr=0;
        for(int i=1;i<=k;i++)
        {
            aux=numar[i]*x+temp;
            temp=aux/10;
            numar[i]=aux%10;
            if(!numar[i] && ok)
            {
                nr++;
            }
            else ok=0;
        }
        if(temp)
            numar[++k]=temp;
        x++;
    }
    fout<<x-1;
    return 0;
}