Cod sursa(job #670371)
| Utilizator | Data | 28 ianuarie 2012 22:06:42 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<fstream>
using namespace std;
fstream fin("fact.in",ios::in),fout("fact.out",ios::out);
int main()
{
int p,ok,t,i,j,a=1,v2=0,v5=0;
fin>>p;
ok=1;
while(ok)
{
i=a;
j=a;
t=0;
while(i%2==0)
{
t++;
i/=2;
}
// fout<<t<<" "<<i<<" ";
v2+=t;
t=0;
while(j%5==0)
{
t++;
j/=5;
}
v5+=t;
if(v5>=p&&v2>=p)
ok=0;
a++;
}
fout<<a-1;
fin.close();
fout.close();
return 0;
}