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.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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.
Name |
---|
Try all $$$A$$$ from $$$-1000$$$ to $$$1000$$$ and $$$B$$$ from $$$-1000$$$ to $$$1000$$$, print anything that works.
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
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.