Cod sursa(job #1834876)

Utilizator zazavatar12Marton Alexandru-Sergiu zazavatar12 Data 25 decembrie 2016 19:39:33
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
// Week 2 - prob 3.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>

using namespace std;

int i, n, nr_de_zero, aux, s = 0, putere = 5;
long long getTrailingZeros(int n);


int main()
{
	//int n, nr_de_zero, s=0, putere=5;
	cin >> nr_de_zero;
	if (nr_de_zero == 0) cout << 1;
	else
	{
		

		if (getTrailingZeros(nr_de_zero) == nr_de_zero)
		{
			cout << i*5 << '\n';
		}
		else cout << "-1\n";
		
	}

    return 0;
}

long long getTrailingZeros(int n)
{
	
	for ( i = 1; s < nr_de_zero; i++)
	{
		if (!(i % 5))
		{
			aux = i;
			while (aux % 5 == 0)
			{
				s++;
				aux /= 5;
			}
			
		}
		s++;
		
	}
	i--;
	return s;
}