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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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.