FisherKK edited 3 年前
This is a past version of blog DFS模板
c++ void DFS(int i, int count, LL s) { if (count == k) { if (isPrime(s)) sum++; return; } for (int h = i; h < n; h++) DFS(h + 1, count + 1, s + arr[h]); }
void DFS(int i, int count, LL s) { if (count == k) { if (isPrime(s)) sum++; return; } for (int h = i; h < n; h++) DFS(h + 1, count + 1, s + arr[h]); }