Pagini recente » Cod sursa (job #1624631) | Cod sursa (job #2334038) | Cod sursa (job #2829960) | Cod sursa (job #2669481) | Cod sursa (job #541288)
Cod sursa(job #541288)
#include <fstream>
using namespace std;
int zerouri(int n) {
int suma=0,x;
x=n;
while(n) {
suma+=n%5;
n/=5;
}
return (x-suma)/4;
}
int main() {
int n,x,z;
bool gasit=false;
ifstream f("fact.in");
f>>n;
f.close();
ofstream g("fact.out");
if(n==0) {
g<<0;
g.close();
return 0;
}
x=n*4;
while((x<n*5) || (gasit==false)) {
z=zerouri(x);
if(z==n) {
gasit=true;
g<<x;
g.close();
return 0;
}
else if(z>n){
break;
} else {
x++;
}
}
g<<-1;
g.close();
return 0;
}