Cod sursa(job #3170059)

Utilizator andrei_btwAndrei Nastasa andrei_btw Data 16 noiembrie 2023 19:01:05
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
ifstream fin("fact.in");
ofstream fout("fact.out");
using namespace std;
int nz(int n) {
    int c2 = 0, c5 = 0;

    for (int i = 2; i <= n; i *= 2) 
    {
        c2 += n / i;
    }

    for (int i = 5; i <= n; i *= 5) 
    {
        c5 += n / i;
    }

    return c5;
}

int main(){
    int p;
    fin>>p;
    int i=1;
    bool ok=false;
    while(ok==false){
        if(nz(i)==p) ok=true;
        i++;
    }
     fout<<i-1;
    return 0;
}