NYOJ--491--dfs(打表水过)--幸运三角形

/*
    Name: NYOJ--491--幸运三角形
    Author: shen_渊
    Date: 15/04/17 16:26
    Description: DFS超时,深搜出第一行的所有情况,计算之后打表水过
                0,0,0,4,6,0,0,12,40,0,0,171,410,0,0,1896,5160,0,0,32757
*/
#include<iostream>
#include<cstring>
using namespace std;
const char ADD = '+';
const char SUB = '-';
void dfs(int);
void cal();
int n,counter;
string str;
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    while(cin>>n){
        counter = ;
        str = "";
        dfs();
        cout<<counter<<endl;
    }
    ;
}
void dfs(int ct){
    if(ct == n){
        cal();
        return;
    }else{
        str[ct] = ADD;
        dfs(ct+);
        str[ct] = SUB;
        dfs(ct+);
    }
}
void cal(){
    int t = n;
    ,sums=;
    while(t){
        int i;
        ; i<t; ++i){
            if(str[i] == ADD)suma++;
            else sums++;
        }
        ; i<t-; ++i){
            ])str[i] = ADD;
            else str[i] = SUB;
        }
        t--;
    }
    if(suma == sums)counter++;
}
#include<iostream>
using namespace std;
] = {,,,,,,,,,,,,,,,,,,,};
int main()
{
    int n;
    ios::sync_with_stdio(false);
    while(cin>>n){
        cout<<arr[n]<<endl;
    }
    ;
}
上一篇:codeforce 600A - Extract Numbers


下一篇:开发微信小程序公司怎么找