Cod sursa(job #3038042)
Utilizator | Data | 26 martie 2023 19:16:18 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int nr(int p)
{
int i = 0;
int cnt = 0;
while(cnt < p)
{
i++;
cnt++;
int x = i;
while(x % 5 == 0)
{
x /= 5;
cnt++;
}
}
if(cnt == p)
{
return 5*i;
}
else
{
return -1;
}
}
int main()
{
int p;
f>>p;
if(p == 0)
{
g<<1;
}
else
{
g<<nr(p);
}
return 0;
}