Cod sursa(job #581698)
| Utilizator | Data | 14 aprilie 2011 15:11:16 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int i,p,s2=0,s5=0,s=0,aux,gasit=0;
fin>>p;
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;
}
