#include<iostream>//不要考虑{}¥相套的情况
#include<cstring>//尽量找简便的思路,A了
#include<cstdlib>
#include<cstdio>
#include <algorithm>
#include<string>
#define large 1003
#define maxn 100000
using namespace std;
int n,flag,tip;
char str[large][5000];
__int64 time,result,space;
int main()
{
while(scanf("%d\n",&n)!=EOF)//这里注意\n,而且要用__int64
{
result=1;
time=0;
space=0;
flag=0;
for(int i=0;i<n;i++)
{
gets(str[i]);
}
for(int i=0;i<n;i++)
{
int len=strlen(str[i]);
for(int j=0;j<len;j++)
{
if(str[i][j]=='{'&&flag==0)
{
time=0;
flag=1;
}
if(flag==1)
{
if(str[i][j]=='|')
time++;
}
if(str[i][j]=='}'&&flag)//单出现}的情况怎么办??!!!
{
result*=(time+1);
flag=0;
time=0;
if(result>maxn)//记得这么搞
break;
}
if(str[i][j]=='$'&&(flag==0))
{
space=2;
flag=-1;
continue;
}
if (flag == -1) //果然是我计算单一空格那里写搓了
{
if (str[i][j] ==' '&& str[i][j+1] ==' ')
space++;
else if (str[i][j] ==' ')
{
result *= space;
space= 2;
}
if(result>maxn)
break;
}
if(str[i][j]=='$'&&(flag==-1))
{
flag=0;
space=2;
continue;
}
}
}
if(result<=maxn)
printf("%I64d\n",result);
else
printf("doge\n");
}
return 0;
}
HDU4891
最新推荐文章于 2019-12-18 20:07:00 发布