Notice
Recent Posts
Recent Comments
Link
목록차이를 최대로 (1)
Be a developer
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ckCiVn/btqtS8wFsJb/u7YennpcTjhOmUpBp6oR6K/img.png)
abs함수와 max함수를 쓴다는 것 외에는 딱히 설명할게 없다. 한 가지 중요한 점은 순열을 사용하기 위해서는 먼저 정렬을 해야 한다는 것이다.(모든 경우를 다 돌려보기 위해서) next_permutation을 사용할 때는 첫 번째 순열을 돌린 후에 해야 하기 때문에 do-while을 사용하자. 시간복잡도는 N이 최대 8이므로 8!로 순열로 해결할 수 있는 문제임을 알 수 있다. 1234567891011121314151617181920212223#include #include using namespace std; int main(int argc, char* argv[]) { int n, ans = 0, sum; cin >> n; int *bf = new int[n]; for (int i = 0; i > ..
알고리즘
2019. 3. 27. 22:28