首页 > 其他 > 详细

清北学堂模拟赛d6t1 角谷猜想

时间:2017-10-06 18:55:53      阅读:243      评论:0      收藏:0      [点我收藏+]

技术分享

技术分享

分析:不用删数字,我们考虑加入数字,维护一个栈,把不是4和7的数加进去,遇到3看栈顶是不是1,是的话弹出来就可以了.

#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n,top;
char c[N],st[N];
int main()
{
    freopen("kakutani.in","r",stdin);
    freopen("kakutani.out","w",stdout);
    cin>>n;
    while(n--)
    {
        scanf("%s",c+1);
        int l=strlen(c+1);
        for(int i=1;i<=l;i++)
        {
            if(c[i]!=4&&c[i]!=7)
                if(c[i]==3&&st[top]==1)top--;
                    else st[++top]=c[i];
        }
        if(!top)cout<<0;for(int i=1;i<=top;i++)cout<<st[i];cout<<endl;
        top=0;
    }

    return 0;
}

 

清北学堂模拟赛d6t1 角谷猜想

原文:http://www.cnblogs.com/zbtrs/p/7631946.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!