Cod sursa(job #2609320)
| Utilizator | Data | 2 mai 2020 13:47:53 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | igorj_mentorat1 | Marime | 0.81 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long cer,n,x,cinci,i,j,pas;
map <long long,int> ok;
void fcinci()
{
while(x % 5 == 0)
{
++ cinci;
x /= 5;
}
}
int main()
{
f >> cer;
if(!cer)
{
g << 1;
return 0;
}
n = 1e3;
for(i = 5; i <= n; i *= 5)
{
++ pas;
j = 1;
while(i * j <= n)
{
ok[i * j] = pas;
++ j;
}
}
i = 5;
while(1)
{
cinci += ok[i];
if(cinci >= cer)
{
if(cinci == cer)
{
g << i;
return 0;
}
g << -1;
return 0;
}
i += 5;
}
}
