Algorithm
BOJ 1182 c++
알고리즘 백준 1182, BOJ 1182 부분수열의 합 c++ #include using namespace std; int n, s; int arr[21]; int cnt = 0; void func(int cur, int total) { if (cur == n) { if (total == s) { cnt++; } return; } func(cur + 1, total); func(cur + 1, arr[cur] + total); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> s; for (int i = 0; i > arr[i]; func(0, 0); if (s == 0) cnt -= 1; cout
2020. 7. 14. 22:24
최근댓글