Cod sursa(job #2803414)
Utilizator | Data | 19 noiembrie 2021 23:23:09 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long p, nr=0,v[1000005],cont=0;
void mult()
{
for (int i = 1; i < p; i++)
{
nr += 5;
if (nr % 25 == 0)
{
cont++;
}
v[i] = nr;
}
}
void ver()
{
if (p < 5)
{
g << v[p];
}
else {
g << v[p - cont];
}
}
int main()
{
f >> p;
if (p == 5)
{
g << -1;
}
else {
mult();
ver();
}
}