Topic 1084: Integer splitting (recursion)

Source: Internet
Author: User

Test instructions

Ask a number of methods that divide the sum of the powers divided into 2.

I'm going to start by looking up the rules for the front.

n Kinds of numbers

1 1

2 2

3 2

4 4

5 4

6 6

7 6

8 10

9 10

10 14

......

1#include <stdio.h>2#include <cstring>3#include <iostream>4#include <algorithm>5#include <cstdlib>6#include <cmath>7#include <vector>8#include <queue>9#include <map>Ten#include <Set> One  A using namespacestd; -  -typedefLong Longll; the  - Const intMoD =1000000000; - intf[1000010]; -  + voidInit () - { +f[1] =1; A      for(intI=2; i<=1000000; i++) at     { -         if(i&1) F[i] = f[i-1]%MoD; -         ElseF[i] = (f[i-1]+f[i/2])%MoD; -     } - } -  in intMain () - { to     intN; + init (); -      while(~SCANF ("%d",&N)) the     { *printf"%d\n", F[n]); $     }Panax Notoginseng     return 0; -}
View Code

Topic 1084: Integer splitting (recursion)

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.