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

Автор Rising_Phoenix7, история, 3 года назад, По-английски

I was thinking about a statement which came up in yesterday's contest where the value of abs(a^x-b^x) was to be minimized. For x less than or equal to r. I was thinking about this problem on these lines:

Let p= abs(a^x-b^x), then 
 p = a^x-b^x or, p = b^x-a^x

 now if we take xor of statement one with a
 p^a = x-(a^b^x)  ..(1)
 and if we take xor of 2nd statement with b 
 p^b = x-(a^b^x)   ..(2)

 We know that both statements are same,

 so p^a=p^b    ..(3)

 Is this analogy correct? If yes, how can we find z for which the statement 3 would be true.
 Any help would be great, Thank you!
  • Проголосовать: нравится
  • -17
  • Проголосовать: не нравится

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

If the range of $$$x$$$ starts with 0 , then the answer is 0 and the value of $$$|a^x-b^x|=0 : a,b \neq 0$$$

If it starts with 1 , then the answer is $$$|a-b|=\max(a,b)-\min(a,b)$$$

and so on ....

Because it can be shown that as long as we increase the power the difference increases

Try graph the problem for different $$$(a,b,x)$$$

»
3 года назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится
  1. You cannot go from $$$p = (a \oplus x) - (b\oplus x)$$$ to $$$p \oplus a = x - (a\oplus b\oplus x)$$$. Xoring both sides by $$$a$$$ gives $$$p\oplus a = a \oplus ((a \oplus x) - (b\oplus x))$$$; you cannot simplify the right side because xor doesn't distribute over subtraction, i.e. $$$s\oplus(t-u)$$$ isn't always equal to $$$(s\oplus t)-(s\oplus u)$$$, for example $$$1 \oplus (4 - 3) = 1 \oplus 1 = 0$$$, while $$$(1 \oplus 4) - (1 \oplus 3) = 5 - 2 = 3 \ne 0$$$.
  2. If you have $$$p\oplus a=p\oplus b$$$, you can xor both sides with $$$p$$$ and the resulting expression $$$p\oplus p\oplus a = p\oplus p\oplus b$$$ is equivalent to the original expression (as xor is invertible). Now, since xor is associative, and $$$s\oplus s=0$$$ is true for all $$$s$$$, the $$$p$$$'s cancel and we get $$$a = b$$$. This means that if $$$a = b$$$, every $$$p$$$ solves the equation $$$p\oplus a=p\oplus b$$$ and if $$$a\ne b$$$, no $$$p$$$ solves that equation.