hdu 4891The Great Pan -----------2014 Multi-University Training Contest 3

题目大意:

      结果ans开始为1,当遇到{||||||} 结构时ans=ans*(|的个数+1),当遇上$ 888 888 $结构时,看其中连续空格数,例子中有三段连续空格每段为n,m,q(n=m=q=1),ans=ans*(n+1)*(m+1)*(q+1),最后如果ans<=100000 输出ans 否则输出doge。

      按照要求写就行了,但是要注意细节决定成败

我的代码:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main (){
  //freopen("input.in","r",stdin);
  //freopen("output.out", "w", stdout);
  int n;
  while (scanf("%d",&n)!=EOF){
    string s1,s2;
    getline (cin,s2);
    for (int i=0;i<n;i++){
      getline (cin,s2);
      s1=s1+s2;
    }
    //cout<<"n="<<n<<endl;
    //cout<<s1<<endl;
    long long x=1,y=1,ans=1;
    bool hx;hx=false;
    bool lh;lh=false;
    for (int i=0;i<s1.size();i++){
      if (s1[i]=='|'&&lh) x++;
      if (s1[i]=='{'&&!lh) lh=true;
      if (s1[i]=='}'&&lh) {
        lh=false;
        ans=ans*x;
        if (ans>100000) break;
        x=1;
      }
      if (s1[i]=='$'){
        if (hx) {
          hx=false;
        }
        else hx=true;
      }
      if (hx&&s1[i]==' '){
        long long yy=1;
        while (s1[i]==' '&&i<=s1.size()) {
            yy++;i++;
        }
        ans=ans*yy;
        if (ans>100000) break;
        i--;
      }
      if (x>100000) {
        ans=100001;
        break;
      }
    }
    if (ans<=100000) cout<<ans<<endl;
    else cout<<"doge"<<endl;
  }
  return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值