Cod sursa(job #537275)

Utilizator jessica26Ileana Stuparu jessica26 Data 20 februarie 2011 15:22:39
Problema Factorial Scor 5
Compilator c Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <stdio.h>
#include <string.h>

int main() {

	int n, p,c, aux, i, sum, max, pow;
	char *path1 = "C:\\Users\\madi\\workspace\\arena\\data.in";
	char *path2 = "C:\\Users\\madi\\workspace\\arena\\data.out";
	//printf(strcat(path, ".in\n"));
	//FILE*f = fopen(path1, "rt");
	FILE*f = fopen("fact.in", "rt");
	fscanf(f, "%d", &p);
	fclose(f);
	/*n = p * 5;
	c = 25;
	while (c < n){
		aux = (int) (n / c);
		for (i = 1; i <= aux; i++)
			if (i * c <= n)
				n -= 5;
		c = c*5;
	}*/
	max = p;
	n = 0;

	for (i = 1; n < p; i++) {
		n++;
		aux = i;
		while (aux%5 == 0) {
			n++;
			aux = aux / 5;
		}
		//i++;
	}


	//f = fopen(path2, "wt");
	f = fopen("fact.out", "wt");
	fprintf(f, "%d\n", n * 5);
	fclose(f);

return 0;
}