You are not logged in. Please login at www.codechef.com to post your questions!

×

[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

dragonemperor's gravatar image

3★dragonemperor
89321134
accept rate: 10%

closed 24 Oct '15, 22:19

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


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

link

answered 07 Oct '15, 00:10

rcsldav2017's gravatar image

5★rcsldav2017
1.1k1229
accept rate: 6%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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