Cod sursa(job #241522)

Utilizator alex23alexandru andronache alex23 Data 10 ianuarie 2009 12:25:33
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <algorithm>

using namespace std;


FILE *f = fopen("loto.in", "r"), *g = fopen("loto.out", "w");

int N, S, a[100], b[1000050];

int main()
{
	fscanf(f, "%d %d\n", &N, &S);
	for (int i = 0; i < N; ++i)
		fscanf(f, "%d", &a[i]);
	fclose(f);


	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			for (int k = 0; k < N; ++k)
				b[i + j + k] = a[i] + a[j] + b[k];

	sort(&b[0], &b[N * N * N + 1]);
	
	fprintf(g, "-1");
	fclose(g);

	return 0;
}