I was wondering if its possible in constant time to calculate the above mentioned goal. I need it to solve a problem on codechef.
How we can find GCD(k + a, k + b) if we already know the GCD(a, b)?
364 Views Asked by Harshit Dubey At
1
There are 1 best solutions below
Related Questions in MATH
- How to restrict vpasolve() to only integer solutions (MATLAB)
- Need clarification on VHDL expressions involving std_logic_vector, unsigned and literals, unsure about compiler interpretation
- What is the algorithm behind math.gcd and why it is faster Euclidean algorithm?
- How to throw a charged particle in a electric vector field?
- Issues with a rotation gizmo and sign flips when converting back to euler angles
- Solving the area of a 2 dimensional shape
- WorldToScreen function
- Algorithm to find neighbours of point by distance with no repeats
- Detecting Circles and Ellipses from Point Arrays in Java
- three parameter log normal distribution
- Bound for product of matrices
- Javascript animation taking incorrect amount of time to reach desired location
- Converting Math.js-like Expressions to Runnable Python Code
- Looking for a standard mathematical function that returns 0 if x = 0 and a constant k when x <> 0
- Partitions in co-lexicographic order (PARI/GP algorithm without recursion)
Related Questions in MATHEMATICAL-OPTIMIZATION
- Best way of finding KKT points for a Sympy polynomial
- CVXPY : Minimising with parameter set to 0 and minimising without parameter gives different answers
- Implementing Constraints in OPL Using CPLEX
- Assigning resources to consumers according lists of preferences
- Dynamic Pricing optimization with volume weighted price constraint
- About MATLAB intlinprog
- Trouble with Refinery Optimization Python Script
- How to handle nondeterministic objective function with scipy.optimization.differential_evolution?
- Non linear programming float decision variable in CPLEX
- If else then constraint to linearization
- How to write solution file for an LP problem with Coin-or Cbc Solver?
- Defining the value of one variable in a constraint in relation to another variable without making the problem nonlinear in Pyomo
- ortools solvers GLOP, PDLP instantly writes that the model is infeasible
- Is there a constraint to pieces of the stateFunction only go in ascending or descending order?
- issues with template <> during scip installation
Related Questions in EUCLIDEAN-ALGORITHM
- Can anyone explain how this code works? GCD, Recursive, Euclidian algorithm
- Prove of Euclid's algorithm of successive subtraction for the greatest common divisor
- Is it possible to implement the extended euclidean algorithm with unsigned machine words?
- How we can find GCD(k + a, k + b) if we already know the GCD(a, b)?
- Time Complexity of Euclid Algorithm by Subtraction
- Implement modInverse using Extended Euclid Algorithm in Java
- Divide by zero, can't find the problem in this program which runs Euclid's algorithm to find the greatest common divisor
- Calculating euclidean distance in a matrix
- Unnormalizing in Knuth's Algorithm D
- I want to get two numbers as input and calculate all the possible differences in Python
- Is there any way to perform this type of recursion in C++ or python?
- Euclidean algorithm explanation?
- Understanding implementation of Extended Euclidean algorithm
- Evaluating implementation of Extended Euclidean algorithm
- Python - Print steps of an extended euclidean algorithm
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It is impossible to compute
gcd(a+k,b+k)in constant time knowing onlygcd(a,b).Suppose that
c,dare any two natural numbers withd < c.Let
Then we know in
O(1)time thatIf we could compute
gcd(a+k,b+k) = gcd(c,d)inO(1)additional time, then we could compute all gcds inO(1)time, which is impossible.Having said all that, it is of course possible that in some cases of interest, knowledge of
gcd(a,b)could lead to faster computation ofgcd(a+k,b+k)than would otherwise be possible.