×

# [closed] Need help with floating point format

 0 1 I am trying to solve https://www.codechef.com/problems/TPRODUCT problem. The solution is simple. But storing number in long long is not enough. So I studied the approach of the editorial. It takes logarithm to solve it. I have two doubts. 1) The logarithmic part is not giving correct answer as floating point operations are not accurate. For second test case, the answer is 105, I am getting 104. Here's my code without modulo operation. http://ideone.com/cEHyJ4 What can I do to fix it? 2) How do I perform the modulo operation on a exponentiation where power is a floating point number? I know modular exponentiation but there base and exponents are integers. What can be done for floating point? asked 06 Oct '15, 10:07 893●2●11●34 accept rate: 10%

### The question has been closed for the following reason "The question is answered, right answer was accepted" by dragonemperor 24 Oct '15, 22:19

 1 hi take log of all values and store a array say A[] and trace all path compare according to question what you need and mark your optimal path and after that just move along that path ans=(ans*curr_node_value_of_optimal_path_original)%MOD; print ans; Take A look at my solution HAPPY CODING answered 07 Oct '15, 00:10 1.1k●12●29 accept rate: 6%

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:

×153
×7

question asked: 06 Oct '15, 10:07

question was seen: 1,337 times

last updated: 24 Oct '15, 22:19