问题 I have two numbers, let's name them N and K , and I want to write N using K powers of 2. For example if N = 9 and K = 4 , then N could be N = 1 + 2 + 2 + 4 ( 2^0 + 2^1 + 2^1 + 2^2 ). My program should output something like N = [1,2,2,4] . I am used to C++. I can't find a way to solve this problem in Prolog. Any help will be appreciated! 回答1: Here's a scheme that uses CLP(FD). In general, when reasoning in the domain of integers in Prolog, CLP(FD) is a good way to go. The idea for this