Pagini recente » Cod sursa (job #1000136) | Cod sursa (job #895798) | Cod sursa (job #2470198) | Cod sursa (job #966596) | Cod sursa (job #541876)
Cod sursa(job #541876)
#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<<1;
g.close();
return 0;
}
x=n*4;
verifica:
if(!gasit) {
z=zerouri(x);
if(z==n) {
gasit=true;
g<<x;
g.close();
return 0;
}
else if(z>n){
gasit=true;
} else {
x++;
}
goto verifica;
}
g<<-1;
g.close();
return 0;
}