DFS模板 (Past)

FisherKK edited 3 年前

This is a past version of blog DFS模板

  • n个数里面挑不同的k个数
    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]); }