HDU4891 The Great Pan 暴力

题意:给你字符串,两种模式,每一种模式有相应规则的不同意思,问你这个字符串一共有多少意思

解题思路:合在一起两种模式暴力

解题代码:

  1 // File Name: 1005.cpp
  2 // Author: darkdream
  3 // Created Time: 2014年07月29日 星期二 15时54分08秒
  4 
  5 #include<vector>
  6 #include<list>
  7 #include<map>
  8 #include<set>
  9 #include<deque>
 10 #include<stack>
 11 #include<bitset>
 12 #include<algorithm>
 13 #include<functional>
 14 #include<numeric>
 15 #include<utility>
 16 #include<sstream>
 17 #include<iostream>
 18 #include<iomanip>
 19 #include<cstdio>
 20 #include<cmath>
 21 #include<cstdlib>
 22 #include<cstring>
 23 #include<ctime>
 24 
 25 using namespace std;
 26 #define LL long long 
 27 LL ans = 0 ;
 28 char str1[1000000];
 29 char str[10000000];
 30 int main(){
 31     int n; 
 32     while(scanf("%d",&n) != EOF)
 33     {
 34     int len = 0;
 35         getchar();
 36         for(int i =1 ;i <= n;i ++)
 37         {
 38         //    printf("%d\n",i);
 39             gets(str1);
 40             int len1 = strlen(str1);
 41           //  printf("%d\n",len1);
 42             for(int j = 0 ;j < len1 ;j++)
 43                 str[j+len] = str1[j];
 44             len = len + len1;
 45         }
 46         int is = 0 ;
 47         ans = 1; 
 48         int t  = 0 ;
 49         LL tans = 1 ;
 50         int ok = 0 ; 
 51         for(int i = 0 ;i < len ;i ++)
 52         {
 53             if(ok == 1)
 54                 break;
 55             if(is)    
 56             {
 57                if(str[i] == ' ')
 58                {
 59                     t++;
 60                     if(str[i+1] != ' ')
 61                     {
 62                         tans *=(t+1);
 63                         t = 0 ; 
 64                     }
 65                }else if(str[i] == '$'){
 66                    is = 0 ;
 67                    ans = tans * ans;
 68                    tans = 1; 
 69                }
 70                if(ans > 100000 || tans > 100000)
 71                 {
 72                      ok = 1; 
 73                 }
 74             }else {
 75              //  printf("****\n");
 76                if(str[i] == '{')
 77                 {
 78             //       printf("****\n");
 79                    int t = 1 ; 
 80                    int j ;
 81                    for(j = i +1; ;j ++)
 82                    {
 83                        if(str[j] == '}') 
 84                            break;
 85                        if(str[j] == '|')
 86                            t ++ ; 
 87                    }
 88                    i = j;
 89                    ans *= t ; 
 90                    if(ans > 100000)
 91                    {
 92                      ok  = 1; 
 93                    }
 94                 }else{
 95                    if(str[i] == '$')
 96                        is = 1; 
 97                 }
 98             }
 99     //        printf("%I64d %d\n",ans,i);
100         }
101         if(ans > 100000 || ok )
102             printf("doge\n");
103         else 
104             printf("%I64d\n",ans);
105     }
106     return 0;
107 }
View Code

 

转载于:https://www.cnblogs.com/zyue/p/3876616.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值