Math, asked by jonalibaishya60, 7 months ago

find the solution of
n= -3​

Answers

Answered by yashbnarale2008
1

Answer:

Suppose you have a linear equation in n variables. The goal is to either determine that no integer solution is possible, or determine the smallest coefficient vector, for an integer solution.

In other words, let ax=b where x is the vector you want to find, and a is a vector of coefficients. b is a scalar constant. Find x such that the sum of x1, ... ,xn is minimized, and all xis are integers. Or, determine that no such x exists. From now on, I will say that |x| is the sum of the xi's.

What is an efficient way to solve this? I feel like this is similar to the Knapsack problem, but I'm not entirely sure.

My Solution

The way I tried to solve this was doing a Breadth-First Search on the space of vectors, where the breadth would be the sum of the vector entries.

At first I did this naively, starting from |x| = 0, but when n is even moderately large, and the solution is non-trivial, the number of vectors generated is enormous (n ^ |x| for each |x| you go through). Even worse, I was generating many duplicates. Even when I found a way to generate almost no duplicates, this way is too slow.

Next, I tried starting from a higher |x| from the beginning, by putting a lower bound on the optimal |x|. I sorted a to have it in decreasing order, then removed all ai > b. Then a lower bound on |x| is b / a[0]. However, from this point, I had difficulty quickly generating all the vectors of size |x|. From here, my code is mostly hacky.

In the code, b = distance, x = clubs, n = numClubs

Step-by-step explanation:

please follow me fast and mark is brain list

Similar questions