summaryrefslogblamecommitdiffstats
path: root/mat/advent/8/prog.c
blob: 172cbe02c03a9046064055aa6954ef19924cf028 (plain) (tree)



























                                                                                                            
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char ** argv) {
	if (argc != 1+3) {
		fprintf(stderr, "uporaba: %s <od> <do> <n>\nprimer: %s 1000 9999 8499\n", argv[0], argv[0]);
		return 1;
	}
	unsigned long long int o = strtoull(argv[1], NULL, 10);
	unsigned long long int d = strtoull(argv[2], NULL, 10);
	unsigned long long int n = strtoull(argv[3], NULL, 10);
	unsigned long long int i = o;
	unsigned long long int j = o;
	unsigned long long int s = 0;
	for (i = o; i <= d; i++) {
		fprintf(stderr, "\rpreostane še %llu iteracij", n-i);
		s = 0;
		for (j = o; j <= d; j++) {
			if (j == i)
				continue;
			s += j;
		}
		if (n * i == s)
			break;
	}
	fprintf(stdout, "\rče seštejemo vsa števila od %llu do %llu, razen %llu, bo\n"
			"vsota vseh %llu, kar je %llu*%llu.\n", o, d, i, s, n, i);
	return 0;
}