Cod sursa(job #122007)
Utilizator | Data | 10 ianuarie 2008 17:31:37 | |
---|---|---|---|
Problema | Factorial | Scor | 65 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include<fstream.h>
unsigned long int p,i,j,x;
int main()
{ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
while((i+j)<(p-5))
{i+=5;
x=i;
while(x%5==0)
{j++;
x=x/5;
}
if((i+j)>p)
{g<<"-1";break;}
while((i+j)<p)
{i++;
x=i;
while(x%5==0)
{j++;
x=x/5;
}
if((i+j)>p)
{g<<"-1";break;}}
if((i+j)==p)
g<<i*5;
}
f.close();
g.close();
return 0;
}