hdu1246

自共轭Ferrers图

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 557    Accepted Submission(s): 316

Problem Description
Ferrers图是一个自上而下的n层格子,且上层格子数不少于下层格子数。
如上图所示,图中的虚线称为Ferrers图的虚轴。若将图一绕虚轴旋转180°,即将第一行与第一列对调,将第二行与第二列对调,……,这样所得到的图仍为Ferrers图,如下图所示。
这两个图称为一对共轭Ferrers图。有一些Ferrers图,沿虚轴转换后的Ferrers图仍为它本身,也就是说这个Ferrers图关于虚轴对称,那么这个Ferrers图称为自共轭Ferrers图。下图便是一个自共轭Ferrers图。
现在我们的目标是寻找的是大小为n的自共轭Ferrers图的总数。所谓大小为n的自共轭Ferrers图是指由n个方格组成的自共轭Ferrers图。
 
Input
输入数据有多行,每行为一个正整数n(1<=n<=300)。表示自共轭Ferrers图的大小为n。
 
Output
对应输入的每一个n,输出一行大小为n的自共轭Ferrers图的总数。
 
Sample Input
1
2
3
 
Sample Output
1
0
1
 
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int i,j,n;
    int a[310]={1,1};
    for(i=3;i<310;i+=2)
        for(j=310;j>=0;j--)
        {
            if(i+j<310)
            {
                a[i+j] += a[j];
            }
        }
        while(cin>>n)
        {
            cout << a[n] << endl;
        }
        return 0;
}
 
 
 
原文地址:https://www.cnblogs.com/Deng1185246160/p/3355798.html