Cod sursa(job #604524)

Utilizator octavianOctavian Crintea octavian Data 23 iulie 2011 02:02:45
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<fstream>
using namespace std;

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

int main()
{
    int n, p, k, aux;

    fin >> p;

    k = n = 0;

    while(k < p)
    {
        n += 5;

        aux = n;

        while(!(aux % 5))
        {
            aux /= 5;
            k++;
        }
    }

    if(k == p) fout << n;
    else fout << -1;

    fin.close(); fout.close();

    return 0;
}