Cod sursa(job #2785424)

Utilizator peterimaria175@gmail.comMaria Peteri [email protected] Data 18 octombrie 2021 17:47:59
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
int main()
{
    int n,p;
    in>>p;
    n=1;
    int s=0;
    int c=5;
    bool ok;
    do
    {
        ok=1;
        while(c<=n)
    {
        s=s+n/c;
        c=c*5;
    }
    if(s!=p)
    {
        s=0;
        c=5;
        n=n+1;
        ok=0;
    }
    }while(ok!=1);
    out<<n;


    return 0;
}