Cod sursa(job #2202771)

Utilizator tim_calinCalin Dragomirescu tim_calin Data 9 mai 2018 20:39:50
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
///infoarena problema factorial
#include <bits/stdc++.h>

using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");
int nrz;

int main()
{
   int contor = 0;
   long long nrcrt = 5;
   long long temp = 0;
   fin >> nrz;
   if (0 == nrz)
        fout << 1;


    while (contor < nrz)
    {
        temp = nrcrt;
        while (temp % 10 == 0) {
            contor++;
            temp /= 10;
        }
        while (temp % 5 == 0) {
            contor++;
            temp /= 5;
        }
        if (contor == nrz)
        {
            fout << nrcrt;
            return 0;
        }
        else
            nrcrt += 5;
    }
    fout << "-1";

    return 0;
}