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

Автор heyyolol, 6 лет назад, По-английски

Given three numbers A, B, C (up to 2 decimal places).

where 0 < A, B, C <= 10000000000

U may arrange them in any order, let X be the first number, Y be the second and Z be the third.

U want to maximise X^Y^Z (where ^ stands for exponentiation)

Output the order which u would arrange A, B and C to achieve the optimum answer.

Thanks in advance :)

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

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Since there are just 3 numbers, that means 6 combinations. So you can calculate the value for each combination separately.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится

Not completely sure about this but I guess this idea should work. Let N = x^y^z. Compute the value of log(log(N)) for all permutations (=6) of the given numbers A,B,C and check for it's maximum.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +19 Проголосовать: не нравится

    Your idea is correct. log(log(x^y^z)) = z * log(y) + log(log(x)), which can be calculated without worry of overflow. However, there's a corner case you should be careful of.

    Corner Case (in case you don't want spoiler)
    • »
      »
      »
      6 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +9 Проголосовать: не нравится
      My logic for corner cases :

      Am I right ?