Cod sursa(job #2865334)

Utilizator astridgastrid grun astridg Data 8 martie 2022 18:52:01
Problema Factorial Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{ int n=1,p,nr=0,cn,k=0;
fin>>p;
if(p==0){
    fout<<1;
}
else{
while(nr<p){
        cn=n;
        k=0;
    while(cn%5==0){
        k++;
        cn=cn/5;
    }
    nr=nr+k;
    //cout<<"testing "<<n<<"\n";
    //cout<<k<<" "<<nr<<"\n";
    n++;
}
if(nr==p){
   fout<<n-1;
}
else{fout<<-1;}
}
    return 0;
}