×

 0 How can I reduce the complexity of my code so that last subtask passes. Link to my code :- https://www.codechef.com/viewsolution/17434010 asked 13 Feb '18, 23:38 3★kunal12 44●5 accept rate: 0%

 1 The loop which is running for i =2 to t-1 should be removed, and matrix exponentiation can be used, which reduces complexity to O(log t). cos(N∗X)=2∗cos(X)∗cos((N−1)∗X)−cos((N−2)∗X), this can be solved by matrix exponentiation. answered 13 Feb '18, 23:53 5★akshat98 11●2 accept rate: 0% cos(N∗X)=2∗cos(X)∗cos((N−1)∗X)−cos((N−2)∗X). How can I solve this using matrix exponentiation (14 Feb '18, 00:03) kunal123★ Consider cos(nx) to be F(n). Therefore F(n)=aF(n-1)-F(n-2), (where a=2cos(x)) this is a linear recurrence. Now this can be solved by matrix exponentiation. For matrix exponentiation goto this link. https://comeoncodeon.wordpress.com/2011/05/08/recurrence-relation-and-matrix-exponentiation/ (14 Feb '18, 00:07) akshat985★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,424
×236
×1

question asked: 13 Feb '18, 23:38

question was seen: 231 times

last updated: 14 Feb '18, 00:09