#include using namespace std; size_t array[212] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211 }; size_t cache[212]; size_t recursive(size_t position, size_t & check){ if (cache[position] != SIZE_MAX) { return cache[position]; } size_t number = 0; for (size_t i = position +1; array[i] <=check && array[i] - array[position] <=14; ++i) { if (array[i] == check){ number += 1; } number += recursive(i, check); } cache[position] = number; return number; } int main() { for (int i = 0; i < 212; i++) { cache[i] = SIZE_MAX; } size_t answer = 0; size_t check = 31; cin >> check; answer = recursive(0,check); cout << answer << endl; /*for (int i = 0; i < 212; i++) { array[i] = true; }*/ /*for (int i = 2; i < 212/2; ++i) { size_t tmp = i; for (int j = 2; tmp * j < 212; ++j) { tmp = i * j; array[tmp] = false; } } cout << "{"; for (int i = 2; i < 212; ++i) { if (array[i] == true) cout << i << ","; } */ }