Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Find a pair of integers (A,B) such that A**5 − B**5 =X for a given integer X..this is from atcoder beginner level contest...How to solve this ? I checked the editorial but it's not clear.

https://atcoder.jp/contests/abc166/tasks/abc166_d .

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

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Try all $$$A$$$ from $$$-1000$$$ to $$$1000$$$ and $$$B$$$ from $$$-1000$$$ to $$$1000$$$, print anything that works.

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

There are limited number of possible combinations one can possible devise. for example if you take 500 for A and even if you subtract from even largest number 499 , you still be getting number > 10**9,so going till 500 is not required . Just check combinations till 126 as some have said in the discussion, i did with 1000

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

You can rewrite the expression as b^5=a^5-x now you can run loop on a from 0 to x^(1/5) and filter those values of a for which a^5-x is perfect 5th power of some integer. From this you can find pair a,b which satisfy given condition.