You will be given two numbers. For example: 20 and 640. You have to test those two numbers on a 3rd number N.

The testing is like this. Let us assume N = 4, then

20/4 = 5

640/4 = 160

since I have no remainder, when N = 4, the answer is 5 and 160

if N = 7

20/7 = 2.857

640/7 = 91.429

when I get a decimal answer, I can choose numbers when I multiply them and sum them I get 20

4x3 + 2x3 + 1x2 = 20, for those numbers I care about the left numbers for example 4x3, I care about 4

then I have 4, 2, and 1

then I look at this number (91.429), reduce it to 91. I am allowed to take 91 or 91 + 1 or 91 - 1, in other words 90, 91, 92

92x4 + 90x2 + 92x1 = 640

then the answer when N = 7 is (4, 92), (2, 90) and (1,92)

I am flexible to answer the same N=7 in a different way if I want

for example

4x2 + 3x4 = 20

91x4 + 92x3 = 640

when N = 7, the answer also could be (4,91) and (3,92)

when N = 12

20/12 = 1.6667

640/12 = 53.333

8x2 + 4x1 = 20

53x8 + 54x4 = 640

the answer when N = 12 is (8,53) and (4,54)

when N = 13

20/13 = 1.538

640/13 = 49.231

I tried to solve this but I could not. Therefore, is there a general formula that can help me to find the answer easily?