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

来源:互联网 发布:沈阳直销软件 编辑:程序博客网 时间:2024/06/06 16:24

题目大意:

      结果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
原创粉丝点击