Cod sursa(job #823888)
| Utilizator | Data | 25 noiembrie 2012 18:17:04 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include<iostream>
using namespace std;
#include<fstream>
int main()
{
int P,x,nr_curent=1;
ifstream f_in("fact.in");
ofstream f_out("fact.out");
f_in>>P;
if(P==0)
{
f_out<<nr_curent;
}
else
{
while(P>0)
{
x=nr_curent;
while(x%5==0)
{
P--;
x=x/5;
}
while(x%10==0)
{
P--;
x=x/10;
}
nr_curent++;
}
f_out<<nr_curent-1;
}
if(P!=0)
f_out<<-1;
return 0;
}