Find the positive integral solutions under certain conditions

54 Views Asked by At

find the positive integral solutions the equation $$ a+b+c+d+e=20,$$ where $a=b$ and $b,c,d,e$ are distinct.

Need good approach, so I can apply on big number too thanks !

1

There are 1 best solutions below

0
On

For moderate numbers (32 bit integers), you could use MiniZinc:

include "globals.mzn";
set of int: Domain = 1..100;
var Domain: a;
var Domain: b;
var Domain: c;
var Domain: d;
var Domain: e;

constraint a == b;
constraint all_different([b, c, d, e]);
constraint (a+b+c+d+e) == 20;

Output:

a = 1;
b = 1;
c = 13;
d = 3;
e = 2;