zoukankan      html  css  js  c++  java
  • vijos

    P1122出栈序列统计
    未递交

    描写叙述

    栈是经常使用的一种数据结构,有n令元素在栈顶端一側等待进栈,栈顶端还有一側是出栈序列。

    你已经知道栈的操作有两·种:push和pop,前者是将一个元素进栈,后者是将栈顶元素弹出。如今要使用这两种操作。由一个操作序列能够得到一系列的输出序列。

    请你编程求出对于给定的n,计算并输出由操作数序列1,2,…。n。经过一系列操作可能得到的输出序列总数。

    格式

    输入格式

    一个整数n(1<=n<=15)

    输出格式

    一个整数,就可以能输出序列的总数目。

    例子1

    例子输入1[复制]

    3

    例子输出1[复制]

    5

    限制

    每一个測试点1s

    来源

    C_0 = 1 /quad , /quad C_{n+1}=/frac{2(2n+1)}{n+2}C_n

    #include <map>
    #include <set>
    #include <ctime>
    #include <queue>
    #include <vector>
    #include <cstdio>
    #include <cctype>
    #include <string>
    #include <cstring>
    #include <sstream>
    #include <cstdlib>
    #include <iostream>
    #include <algorithm>
    
    
    
    
    using namespace std;
    
    
    #define pb push_back
    #define mp make_pair
    #define fillchar(a, x) memset(a, x, sizeof(a))
    #define copy(a, b) memcpy(a, b, sizeof(a))
    #define S_queue<P> priority_queue<P, vector<P>,greater<P> >
    
    
    typedef long long LL;
    typedef pair<int, int > PII;
    typedef unsigned long long uLL;
    template<typename T>
    void print(T* p, T* q, string Gap = " "){int d = p < q ? 1 : -1;while(p != q){cout << *p;p += d;if(p != q) cout << Gap; }cout << endl;}
    template<typename T>
    void print(const T &a, string bes = "") {int len = bes.length();if(len >= 2)cout << bes[0] << a << bes[1] << endl;else cout << a << endl;}
    
    const int INF = 0x3f3f3f3f;
    const int MAXM = 1e5;
    const int MAXN = 1e4 + 5;
    int A[MAXN];
    
    int main(){
        int n;
        scanf("%d", &n);
        int ans = 1;
        for(int i = 1;i <= n;i ++){
            ans = 2 * (2 * (i - 1) + 1) * ans / (i + 1);
        }
        print(ans);
        return 0;
    }
    


  • 相关阅读:
    随机二分图
    城市旅行
    JZPKIL
    线性基专题总结
    杜教筛专题总结
    [NOI2018]你的名字
    P1120 小木棍 [数据加强版]
    先序遍历
    P1736 创意吃鱼法
    P2258 子矩阵
  • 原文地址:https://www.cnblogs.com/cynchanpin/p/6896404.html
Copyright © 2011-2022 走看看