201703 HNSDFZ Training r1t1 B June's education

Source: Internet
Author: User
Description

B June recently heard of a very amazing nature, set P=1+i p=1+i, for each Gaussian integer
X+yi x + yi, we can all find a non-negative integer set S satisfying ∑k∈spk=x+yi () \sum _{k∈s}{p^k} = X+yi ()
And all you have to do is output the set of s in the case of input x and Y.
If you do not understand the above topic, we formally give the following definition.
is for a complex number (Complex number), if his real and imaginary parts are integers, we call them Gaussian integers.
The S collection cannot have the same elements, and each element must be a non-negative integer.

Input

A row of two integers, x, Y. Output

Each line of an integer, from small to large output, represents the collection S. Sample Input

2 0 Sample Output

2
3 Hint

For 100% of data, meet |x|,|y|<=1018 |x|,|y|.
For 50% of data, y = 0 is met.
For 50% of data, meet |x|,|y|<=102 |x|,|y|.
The above two parts 50% are independent of each other. Solving

By playing the PK P^k, you can find a mysterious law: pn=−2 (pn−1+pn−2) p^n = -2 (P^{n-1}+p^{n-2})
The proof is simple:
−2 (pn−1+pn−2) ====−2[pn−2x (p+1)]pn−2x (−2i) PN−2XP2PN

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.