#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdint.h> #include <math.h> #include <stdlib.h> #define TRUE (1 == 1) #define FALSE (1 != 1) #define DEBUG if (FALSE) #define MAX_CASES 110 /* * Author: * Date: * Purpose: * Problem: */ /* * This template reads data until a terminating value is reached. */ int max; int cnt; int p[MAX_CASES]; int sizes[MAX_CASES]; void init() { /* FUNCTION init */ int i; for (i=0; i<max+1; i++) { sizes[i] = 0; } } /* FUNCTION init */ void dump() { /* FUNCTION dump */ int i; printf("cnt = %d max width = %d\n", cnt, max); for (i=0; i<cnt; i++) { /* dump p */ printf(" %d: %d\n", i, p[i]); } /* dump p */ printf("sizes:\n"); for (i=0; i<MAX_CASES; i++) { /* for */ if (0 != sizes[i]) { printf("%d\n", i); } } /* for */ } /* FUNCTION dump */ void getInput() { /* FUNCTION getInput */ int i; p[0] = 0; /* stick in first wall */ scanf(" %d %d ", &max, &cnt); cnt++; for (i=0; i<cnt; i++) { /* for */ scanf(" %d ", &p[i+1]); } /* for */ p[cnt++] = max; /* add last wall */ } /* FUNCTION getInput */ void process() { /* FUNCTION process */ int i; int k; for (i=0; i<cnt; i++) { /* start with ith wall */ for (k=i+1; k<cnt; k++) { /* try each remaining wall */ sizes[p[k] - p[i]] = 1; } /* try each remaining wall */ } /* start with ith wall */ for (i=0; i<MAX_CASES; i++) { /* for */ if (0 != sizes[i]) { printf("%d ", i); } } /* for */ printf("\n"); } /* FUNCTION process */ int main () { /* main */ getInput(); init(); process(); return EXIT_SUCCESS; } /* main */