Mai intai trebuie sa te autentifici.

Cod sursa(job #2577949)

Utilizator Nico10Nicola Andrei George Nico10 Data 10 martie 2020 10:36:16
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p, n, cnt2, cnt5;
bool ok=1;
int cnt=2, copcnt;

int main()
{
    fin>>p;
    if(p==0){
        fout<<1;
        return 0;
    }

    while(ok){
        copcnt=cnt;
        while(copcnt){

            while(copcnt%2==0){
                copcnt/=2;
                cnt2++;
            }

            while(copcnt%5==0){
                copcnt/=5;
                cnt5++;
            }

            copcnt=0;
        }
        if(min(cnt2, cnt5)==p){
            fout<<cnt;
            ok=0;
            return 0;
        }
        cnt++;
    }


    return 0;
}