Cod sursa(job #2696952)
Utilizator | Data | 17 ianuarie 2021 13:38:21 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
unsigned long long n,l,p,i,nr,f,j,ok=0;
in>>p;
l=pow(10,p);
for(i=1;i<=100000000;i++){
f=1;
for(j=1;j<=i;j++)
f=f*j;
if(f%l==0){
ok=1;
nr=i;
break;
}
}
if(ok==1)
out<<nr;
else out<<-1;
return 0;
}