Pagini recente » Cod sursa (job #702206) | Cod sursa (job #296837) | Cod sursa (job #485883) | Cod sursa (job #489024) | Cod sursa (job #541290)
Cod sursa(job #541290)
#include <fstream>
using namespace std;
unsigned long long int zerouri(unsigned long long int n) {
unsigned int suma=0;
unsigned long long x;
x=n;
while(n) {
suma+=n%5;
n/=5;
}
return (x-suma)/4;
}
int main() {
unsigned long long 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;
}