"Bzoj 1197" [HNOI2006] the magic of the flower Fairy

Source: Internet
Author: User

1197: [HNOI2006] Flower Fairy Magic Time limit: ten Sec Memory Limit: 162 MB
Submit: 771 Solved: 448
[Submit] [Status] Description

Input

Contains two integers, separated by a space, the first integer represents the number of times the magic is applied M, and the second integer represents the dimension n of the space. Among them, 1≤m≤100,1≤n≤15.

Output

Contains only an integer that indicates how many different flowers the flower fairy can get after it implements M magic in n-dimensional space.

Sample Input3 1Sample Output6

Dp.


Test instructions is equivalent to placing m n-dimensional balls, up to a few parts of the n-dimensional space.


F[I][J] means that a J i-dimensional ball placed in an i-dimensional space divides the space into several parts.


F[I][J]=F[I][J-1]+F[I-1][J-1]


Consider putting in the first J Ball, has been divided into f[i][j-1] space;


Because I sphere the part that intersects with the I-dimensional ball becomes i-1 dimension (line intersection is point, the intersection is line ...) ), the first J ball intersects with j-1 balls, so it is f[i-1][j-1].


#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include < Cstdlib> #define LL Long longusing namespace Std;int n,m; LL F[105][105];int Main () {        scanf ("%d%d", &m,&n), for (int i=1;i<=m;i++) f[1][i]=i*2;f[2][1]=2;for (int i =2;i<=n;i++) for (int j=2;j<=m;j++) {if (j==1) F[i][j]=4;else f[i][j]=f[i][j-1]+f[i-1][j-1];} Cout<<f[n][m]<<endl;return 0;}



Sentiment:

1.WA is due to initialization of write error


2. Initialize F[1][i] Why is it equal to 2*i? Because in a straight line, two endpoints are added each time, the maximum number of lines can be divided into two parts ("part" and test instructions consistent)

"Bzoj 1197" [HNOI2006] the magic of the flower Fairy

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.