Demo entry 6718263

test

   

Submitted by anonymous on Mar 03, 2018 at 07:36
Language: C++. Code size: 606 Bytes.

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int MAX = 200;
 int dp[MAX][MAX];

void divideNumber()
{
    for (int i = 1; i<MAX; i++)
    {
        dp[i][1] = dp[1][i] = dp[0][i] = 1;
    }
    for (int i = 2; i<MAX; i++)
    {
        for (int j = 2; j<MAX; j++)
        {
            if (j <= i) dp[i][j] = dp[i][j - 1] + dp[i - j][j];
            else dp[i][j] = dp[i][i];
        }
    }
}
int main()
{
    int n;
    divideNumber();
    cout<<"要划分的整数(0-100):";
    cin>>n;
    cout<<dp[n][n]<<endl;
    return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).