Cod sursa(job #581696)
| Utilizator | Data | 14 aprilie 2011 15:10:07 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include<fstream>
using namespace std;
ifstream fin("factorial.in");
ofstream fout("factorial.out");
int main()
{
int i,p,s2=0,s5=0,s,aux,gasit=0;
for(i=1;!gasit;i++)
{
aux=i;
while(aux%2==0)
{
s2++;
aux/=2;
}
while(aux%5==0)
{
s5++;
aux/=5;
}
if(s2<s5)
{
s+=s2;
s5-=s2;
}
else
{
s+=s5;
s2-=s5;
}
if(s==p)
{
fout<<i<<'\n';
gasit=1;
}
}
fin.close();
fout.close();
return 0;
}
