Hdu 2709 Sumsets

Source: Internet
Author: User

Question:

Divide n into the sum of several numbers, which is a positive integer equal to 2 ^ x.

Code:
 
# Include <stdio. h>
_ Int64 I, a [1000001] = {, 2 };
Int main ()
{
For (I = 3; I <1000001; I ++)
{
If (I & 1) = 1)
{
A [I] = a [I-1]; // I is an odd number the same as the previous one
}
Else
{
A [I] = (a [I-2] + a [I> 1]) % 1000000000; // contains 1: a [I-1] fill in 11 for each case, not including 1: a [I/2] each case * 2
}
}
While (scanf ("% I64d", & I )! = EOF)
{
Printf ("% I64d \ n", a [I]);
}
Return 0;
}


 

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.