答案为:20,5,4,2,0
18,9,3,2,0
15,10,3,2,0
12,6,4,2,0
#include <iostream> using namespace std; int cm(int a, int b) { int temp; int mul; mul = a * b; if(a % b == 0) return a; else { while(a % b != 0) { temp = a % b; a = b; b = temp; } return mul * b; } } int main() { int a, b, c, d ; int temp; int ta,tb,tc,td; for(a = 20; a >= 5; a--) for(b = a - 1; b >= 4;b --) for(c = b - 1; c >= 3; c--) for(d = c - 1; d >= 2; d--) { temp = cm(a, b); temp = cm(temp, c); temp = cm(temp, d); ta = temp / a; tb = temp / b; tc = temp / c; td = temp / d; if(ta + tb + tc + td == temp) cout << a << "," << b <<"," << c <<"," << d <<","<<"0" << endl; } return 0; }