hdu 4891 The Great Pan

#include<stdio.h>
#include<string>
#include<string.h>
#include<iostream>
using namespace std;
string s;
char tmp[2000000];
int main()
{
    int snum;//s
    int lnum;//{
    int n;
    int i,j;
    __int64 ans;
    while(scanf("%d",&n)!=EOF)
    {
        snum=0;
        lnum=0;
        ans=1;
        s.clear();
        getchar();
        while(n--)
        {
            cin.getline(tmp,2000000);//会超时
            gets(tmp);
            s+=tmp;
        }
        //cout<<s<<endl;
        for(i=0; i<s.length(); i++)
        {
            if(s[i]==‘{‘)
            {
                i++;
                while(i<s.length()&&s[i]!=‘}‘)
                {
                    if(s[i]==‘|‘)
                    {
                        snum++;
                    }
                    i++;
                    if(ans*(snum+1)>100000)break;
                }
                ans*=(snum+1);
                snum=0;//容易忽略
                if(ans>100000)break;
                //printf("#%d\n",snum);
            }
        }
        for(i=0; i<s.length(); i++)
        {
            if(s[i]==‘$‘)
            {
                i++;
                while(i<s.length()&&s[i]!=‘$‘)
                {
                    if(s[i]==‘ ‘)
                        lnum++;
                    else
                    {
                        ans*=(lnum+1);
                        lnum=0;
                    }
                    i++;
                    if(ans*(lnum+1)>100000)break;
                }
                ans*=(lnum+1);
                lnum=0;//容易忽略
                if(ans>100000)break;
            }
        }
        if(ans>100000)printf("doge\n");
        else printf("%I64d\n",ans);
    }
    //printf();
    return 0;
}

1.

$$之间每出现连续的n个空格,乘以n+1;

{|}计算|的个数为n,乘以n+1。

hdu 4891 The Great Pan,布布扣,bubuko.com

时间: 2024-08-05 11:55:08

hdu 4891 The Great Pan的相关文章

hdu 4891 The Great Pan(模拟)

题目链接:hdu 4891 The Great Pan 题目大意:给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn+1), si表示连续的空格数. 2.{}中间,即 | 的个数+1. 解题思路:模拟. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1<<22

hdu 4891 The Great Pan (模拟)

为什么要开__int64 巨巨在哪~ # include <stdio.h> # include <algorithm> # include <string.h> using namespace std; int main () { __int64 count; int i,len,cot,cot1,j,flag,n; char a[1001][1030]; while(~scanf("%d",&n)) { getchar(); flag=0

HDU 4891 The Great Pan (字符串处理)

题目链接:HDU 4891 The Great Pan 求一串字符有多少种不同的意思,当中关心'{','}'之间的'|'. 和'$','$'之间的空格,连续N个空格算N+1种. AC代码: #include<stdio.h> #include<string> #include<string.h> using namespace std; char s[2*1024*1024+10]; string ss; int cnt; int find(int x,int y) {

2014多校第三场1005 || HDU 4891 The Great Pan(模拟)

题目链接 题意 : 给你n行字符串,问你有多少种理解方式.有两大类的理解 (1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D. (2)$blah blah$,在$$这两个符号中间,如果是不连续的空格的那个位置就有2种理解方式,可以理解为没有空格也可以理解为有空格.如果有连续N个空格的位置,那里就有N+1种理解方式. 最后所有的理解方式相乘,数据保证$一定与$匹配,{一定与匹配},不会有任何嵌套,类似{$$}或者{{}}或者${}$这种情况都不会出现,也不会有{$}这种情况

2014多校联合三 (HDU 4888 HDU 4891 HDU 4893)

HDU 4891 The Great Pan 签到题  他怎么说你就怎么做就好了  注意做乘法时候会爆int 代码: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; int n; char s[2000000]; int flag1, flag2, sp, ansflag;

HDU 4891 简单模拟

The Great Pan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1035    Accepted Submission(s): 355 Problem Description As a programming contest addict, Waybl is always happy to take part in vario

HDU 4891

一道简单的模拟题 需要要匹配{} 和 $$ 符里面的东西即可 //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> #include <iostream> #include <cstring> #include <cmath> #include <stack> #include <queue> #incl

HDU4891_The Great Pan_字符串水题

2014多校第五题,当时题面上的10^5写成105,我们大家都wa了几发,改正后我和一血就差几秒…不能忍 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4891 The Great Pan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 966    Accepted Submission(s

hdu 6166 Senior Pan

地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6166 题目: Senior Pan Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 245    Accepted Submission(s): 71 Problem Description Senior Pan fails i