Cod sursa(job #835167)
Utilizator | Data | 15 decembrie 2012 20:13:36 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,n=1,a,nr,c,z=1;
long b;
int main()
{ f>>p;
if(p==0) { g<<"1";
z=0;
}
while(z) { a=1;
b=1;
while(a<=n) { b*=a;
++a;
}
c=0;
nr=0;
while(c>1) { c=b%10;
b/=10;
if(c==0)++nr;
}
if(nr==p) { g<<n;
z=0;
}
++n;
}
return 0;
}