2018 Spring Training STL

https://cn.vjudge.net/contest/234044#overview
总体而言一部分傻逼题一部分难题
A.
傻逼题1
拿stack模拟一下即可。

#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
int main()
{
    int n,i,j,k;
    string str1,str2;
    while(cin>>n){
        cin>>str1>>str2;reverse(str2.begin(),str2.end());
        vector<int>ans;
        stack<int>sta1,sta2;
        for(i=0;i<str2.size();i++)sta2.push(str2[i]);
        for(i=0;i<str1.size();i++){
            ans.push_back(1);sta1.push(str1[i]);
            while(!sta1.empty()&&sta1.top()==sta2.top())
                sta1.pop(),sta2.pop(),ans.push_back(2);
        }
        if(!sta1.empty()){
            puts("No.");
        }
        else{
            puts("Yes.");
            for(i=0;i<ans.size();i++)
                if(ans[i]==1)
                    puts("in");
                else puts("out");
        }
        puts("FINISH");
    }

    return 0;
}

B.HDU1023
裸的卡特兰数,不知道的话这题可以弃疗了(比如像本蒟蒻,摔
这里写图片描述
这里写图片描述
要么打表,网上有卡特兰数的表,要么递推求,int128是水不过去的,老老实实写高精吧,或者赶紧学一波java(摔

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;

const int maxn = 1000;

struct bign{
    int d[maxn], len;

    void clean() { while(len > 1 && !d[len-1]) len--; }

    bign()          { memset(d, 0, sizeof(d)); len = 1; }
    bign(int num)   { *this = num; }
    bign(char* num) { *this = num; }
    bign operator = (const char* num){
        memset(d, 0, sizeof(d)); len = strlen(num);
        for(int i = 0; i < len; i++) d[i] = num[len-1-i] - '0';
        clean();
        return *this;
    }
    bign operator = (int num){
        char s[20]; sprintf(s, "%d", num);
        *this = s;
        return *this;
    }

    bign operator + (const bign& b){
        bign c = *this; int i;
        for (i = 0; i < b.len; i++){
            c.d[i] += b.d[i];
            if (c.d[i] > 9) c.d[i]%=10, c.d[i+1]++;
        }
        while (c.d[i] > 9) c.d[i++]%=10, c.d[i]++;
        c.len = max(len, b.len);
        if (c.d[i] && c.len <= i) c.len = i+1;
        return c;
    }
    bign operator - (const bign& b){
        bign c = *this; int i;
        for (i = 0; i < b.len; i++){
            c.d[i] -= b.d[i];
            if (c.d[i] < 0) c.d[i]+=10, c.d[i+1]--;
        }
        while (c.d[i] < 0) c.d[i++]+=10, c.d[i]--;
        c.clean();
        return c;
    }
    bign operator * (const bign& b)const{
        int i, j; bign c; c.len = len + b.len;
        for(j = 0; j < b.len; j++) for(i = 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值