#include #include // Problem 524 int n; bool prime(int x) { return (x==31 || x==29 || x==23 || x==19 || x==17 || x==13 || x==11 || x==7 || x==5 || x == 3); } void print(int prefix[17], int l) { // print all combinations that start with the first l numbers in prefix // used just says which numbers are used in that prefix if (l==n) { if (prime(prefix[1] + prefix[n])){ for (int i=1; i> n; while (n) { if (instance > 1) cout << "\n"; cout << "Case " << instance++ << ":\n"; int prefix[17]; prefix[1]=1; print(prefix, 1); cin >> n; } }