码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 4891 The Great Pan

时间:2014-07-29 21:40:12      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   div   ar   

#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

hdu 4891 The Great Pan

标签:style   blog   color   os   io   for   div   ar   

原文地址:http://www.cnblogs.com/XDJjy/p/3876278.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!