Question

In: Computer Science

you are givena pair (a,b) .after eatch unit of time pair(a,b) getd changeed to (b-a,b+a).you are...

you are givena pair (a,b) .after eatch unit of time pair(a,b)
getd changeed to (b-a,b+a).you are given the initial value of
pair and an integer n and you have to print the value of the pair at the nth unit of time

Solutions

Expert Solution

here we consider the time to be starting from t=0

so at t=0 we have

at we have

now following the same pattern and making the first value as

first value = second value - first value

and second value as

second value = second value + first value

we get

at t=2 we have  

now following same pattern we have at

t=3  

at we have

so from this we can see that at every even position we are getting   and at every odd position we are getting  

here we take the base case for t=0 and t=1 to be respectively as it is given in question

so final anwer would be the following relation

ans= (a,b) if n=0

(b-a,b+a) if n =1

(n*a, n*b) if(n>0 and n is even)

( (n-1)*(b-a),(n-1)*(b+a)) (if n>1 and n is odd)


Related Solutions

given pair (a,b) after each unit of time pair (a,b) get changed to (b-a,b+a).you are given...
given pair (a,b) after each unit of time pair (a,b) get changed to (b-a,b+a).you are given the initial value of pair and an integer n and you to print the value of pair at the nth unit of time. input format: 1.First line:t donating the number of test cases 2.Next t lines:three space-seperated integer a,b and n output format : for each test case ,print two integers (mod 10^9 +7) per line denoting the value of the pair at the...
For each pair a, b with a ∈ R − {0} and b ∈ R, define...
For each pair a, b with a ∈ R − {0} and b ∈ R, define a function fa,b : R → R by fa,b(x) = ax + b for each x ∈ R. (a) Prove that for each a ∈ R − {0} and each b ∈ R, the function fa,b is a bijection. (b) Let F = {fa,b | a ∈ R − {0}, b ∈ R}. Prove that the set F with the operation of composition of...
For the given pair of events A and​ B, complete parts​ (a) and​(b) below. ​ A:...
For the given pair of events A and​ B, complete parts​ (a) and​(b) below. ​ A: A marble is randomly selected from a bag containing 14 marbles consisting of 1​ red, 9 ​blue, and 4 green marbles. The selected marble is one of the green marbles. ​ B: A second marble is selected and it is the 1 red marble in the bag. a. Determine whether events A and B are independent or dependent.​ (If two events are technically dependent...
Two numbers a and b are called pythagorean pair if both a and b are integers...
Two numbers a and b are called pythagorean pair if both a and b are integers and there exists an integer c such that a2 + b2 = c2. Write a function pythagorean_pair(a,b) that takes two integers a and b as input and returns True if a and b are pythagorean pair and False otherwise.
Mr. B is a 52 year-old man in the surgical intensive care unit after a liver...
Mr. B is a 52 year-old man in the surgical intensive care unit after a liver transplantation the previous day. He has a 15-year history of hepatic cirrhosis secondary to alcohol abuse. He is intubated and receiving multiple vasopressor medications for hypotension. He also has a triple lumen subclavian central line with TPN infusing. It is 1 hour post-op, The SICU nurse is reassessing the patient. Assessment findings for Mr. B include: Grimacing, can barely bend his fingers, coughing with...
Let a and b be integers. Recall that a pair of Bezout coefficients for a and...
Let a and b be integers. Recall that a pair of Bezout coefficients for a and b is a pair of integers m, n ∈ Z such that ma + nb = (a, b). Prove that, for any fixed pair of integers a and b, there are infinitely many pairs of Bezout coefficients.
Find a pair of vectors, a → and b → that satisfy all of the following...
Find a pair of vectors, a → and b → that satisfy all of the following conditions: a → + b → = 〈 9 , 5 , 5 〉 a → is parallel to 〈 5 , 1 , 2 〉 b → is orthogonal (perpendicular) to {5,1,2}
Learning Objectives After the successful completion of this learning unit, you will be able to: Implement...
Learning Objectives After the successful completion of this learning unit, you will be able to: Implement syntactically correct C++ arrays. Solve a variety of standard problems using arrays. Array Practice I recommend that before you begin the assignment you write as many of these small ungraded programming challenges as you can. You should at least write 2 or 3 of them. They are a good way to gradually build up your confidence and skills. Of course, you'll have to write...
. Recall from the previous page that for each pair a, b with a ∈ R...
. Recall from the previous page that for each pair a, b with a ∈ R − {0} and b ∈ R, we have a bijection fa,b : R → R where fa,b(x) = ax + b for each x ∈ R. (b) Let F = {fa,b | a ∈ R − {0}, b ∈ R}. Prove that the set F with the operation of composition of functions is a non-abelian group. You may assume that function composition is associative
Two players A and B play a game of dice . They roll a pair of...
Two players A and B play a game of dice . They roll a pair of dice alternately . The player who rolls 7 first wins . If A starts then find the probability of B winning the game ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT