HRBEU 占武卖花

占武卖花

TimeLimit: 1 Second   MemoryLimit: 64 Megabyte

Totalsubmit: 8   Accepted: 2  

Description

占武是经济学班的学生,不过和那些理论家不同,占武是个务实型。他始终认为任何经济活动脱离了实际操作都是不可靠的。最近他在学习心理经济学,为了检测商品配置对购物者心理的影响,他决定采购一些漂亮的花儿出售(顺便也赚些零花钱)。占武认为相同的花儿的不同搭配和摆放顺序对买花的女孩有不一样的吸引力,现在他联系了出售商,准备购置君子兰、龙吐珠、六月雪、盆景松四种花。
他把卖花的地点选在大美侧旁的广场(因为他觉得那儿的漂亮女孩最多),他决定将花儿摆成一排,当然由于场地所限一排最多可以放置30盆花。                    
在花儿的搭配上占武认为龙吐珠应该成对出现,也就是说龙吐珠的数目必须是偶数,而君子兰的数目恰恰相反,应该是奇数才好看,除此之外,占武希望在他的摆放中至少应该有一盆六月雪(因为在众多的女孩中六月雪受欢迎排名度是最高的)。
现在占武决定带着他的花儿去广场,他想知道对于N个连续位置,能有几种摆放方案。

Input

给定正整数N( 1<= N <= 30)
输入以0结束

Output

对于给定的N,输出相应可能的摆放方案数。

Sample Input

2
3
0

Sample Output

5
19

 

#include<functional>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<list>
#include<set>
#include<map>

using namespace std;

typedef long long LL;
template<class T> inline void RST(T &A){memset(A,0,sizeof(A));}
template<class T> inline T& RD(T &x){
    scanf("%d",&x);
    return x;
}

LL C[31][31];
LL ans[40];
void init(){
    RST(ans);
    RST(C);
    for(int i=1;i<=30;++i){
        C[i][0]=1;
        C[i][i]=1;
        for(int j=1;j<i;++j)
            C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
    for(int a=0;a<=30;++a){
        if(a&1) continue;
        for(int b=0;b<=30;++b){
            if((b&1)==0&&b!=0) continue;
            for(int c=1;c<=30;++c){
                if(a+b+c>30) continue;
                for(int d=0;d<=30;++d){
                    if(a+b+c+d>30) continue;
                    LL now=1,nex=0;
                    int n=a+b+c+d;
                    now*=C[n][a];
                    n-=a;
                    now*=C[n][b];
                    n-=b;
                    now*=C[n][c];
                    ans[a+b+c+d]+=now;
                }
            }
        }
    }
}

int main(){
    init();
    int n;
    while(RD(n),n)
      printf("%lld\n",ans[n]);
    return 0;
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值