Cod sursa(job #2197699)

Utilizator cosminionutCosmin Ionut cosminionut Data 22 aprilie 2018 18:31:58
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <fstream>
#include <iostream>
#include <cmath>
using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int P;
int N;

void test(int p) {
	// naiv
	unsigned long long prod = 1;
	unsigned long long i = 1;
	unsigned long long P = (unsigned long long)pow(10, p);
	while (i < 50) {
		cout << prod << "\n";
		if (prod % P == 0) {
			cout << i << "\n";
			break;
		}
		i += 1;
		prod *= i;
	}
}

void a(int p) {
	// testeaza numere din 5 in 5
	if (p == 0)
		g << 1 << " \n";
	else {
		int count = 0;
		int x, aux;
		for (x = 0; count < p;) {
			x += 5;
			aux = x;
			while (aux % 5 == 0) { aux /= 5; count++; }
		}
		g << x << "\n";
	}
}

int main() {
	/*cin >> P;
	if (P == 1) {
		N = 0;
	}

	cout << N;*/
	//test(1);

	f >> P;
	a(P);
	return 0;
}