Pagini recente » Cod sursa (job #2086672) | Cod sursa (job #3317102) | Cod sursa (job #3305941) | Cod sursa (job #3324817) | Cod sursa (job #1097740)
#include <fstream>
using namespace std;
int P, N = 99999, c = 0, cif;
long f;
int fx(int n){
if(n == 0){
return 1;
}else{
return(n * fx(n - 1));
}
}
int find_N(){
int x = 0;
while(N == 99999){
f = fx(x);
while(f != 0){
cif = f%10;
f = f/10;
if(cif == 0){
c++;
}
while(cif == 0){
cif = f%10;
f = f/10;
c++;
}
}
if(c == P){
if(x < N){
N = x;
}
}
x++;
}
return N;
}
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>P;
g<<find_N();
}