Cod sursa(job #1747632)
| Utilizator | Data | 25 august 2016 11:49:28 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
long NUM;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
long i=5, nr=0,temp;
bool divisible = true;
fin>>NUM;
while(nr<NUM)
{
temp=i;
while(divisible)
{
if(temp%5==0){
nr++;
temp/=5;
}
else
divisible=false;
}
divisible=true;
i+=5;
}
if(nr == NUM)
fout<<i-5;
else
fout<<"-1";
return 0;
}
