Блог пользователя kelzzin2_fan

Автор kelzzin2_fan, история, 18 месяцев назад, По-английски

Hello, I recently encountered a problem on Kattis which seems to be just be an implementation problem with precision issues that might need to be handled. However, after several WAs with no leads, I am at a dead end. I'm not even sure if it's precision related at the moment...

Below is my approach:

My Approach

My code:

My Code

Any help would be appreciated, thanks!

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
18 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Whatever you are doing inside the loop isn't very clear. Also, never do integral arithmetic in the real number domain. Google Stern-Brocot_tree.

  • »
    »
    18 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    The while loop here serves 2 purposes, i1 and i2 here represent the index of the decimal point if any, I wanted C and F to be integers, so I calculate k = some power of 10 and try to "multiply" C and F into integers. Lastly I parse it into actual integers by removing the decimal point.

    Since I multiplied by k, I have to divide by k as well to get A back. Hence the floor/ceil division happening later down the line. This means all arithmetic should be only done with integers supposedly.

    Thanks for the pointer for Stern-Brocot_tree tho!