• HDU 4891 The Great Pan (题意题+模拟)


    题意:给定一个文章,问你有多少种读法,计算方法有两种,如果在$中,如果有多个空格就算n+1,如果是一个就算2的次方,如果在{}中,

    那么就是把每个空格数乘起来。

    析:直接模拟,每次计算一行,注意上一行最后有空格,下面第一个也是,要全部算上。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <cmath>
    #include <stack>
    #define debug puts("+++++")
    //#include <tr1/unordered_map>
    #define freopenr freopen("in.txt", "r", stdin)
    #define freopenw freopen("out.txt", "w", stdout)
    using namespace std;
    //using namespace std :: tr1;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const LL LNF = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 1e3 + 5;
    const LL mod = 1e9 + 7;
    const int N = 1e6 + 5;
    const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
    const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
    const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
    inline LL gcd(LL a, LL b){  return b == 0 ? a : gcd(b, a%b); }
    inline int gcd(int a, int b){  return b == 0 ? a : gcd(b, a%b); }
    inline int lcm(int a, int b){  return a * b / gcd(a, b); }
    int n, m;
    const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    inline int Min(int a, int b){ return a < b ? a : b; }
    inline int Max(int a, int b){ return a > b ? a : b; }
    inline LL Min(LL a, LL b){ return a < b ? a : b; }
    inline LL Max(LL a, LL b){ return a > b ? a : b; }
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    char s[1000000];
    const int ttt = 100000;
    int main(){
        while(scanf("%d", &n) == 1){
            getchar();
            LL ans = 1;
            bool ok = false;
            bool is = false;
            int cnt1 = 0, cnt2 = 0;
            bool ok1 = false;
            bool ok2 = false;
            while(n--){
                gets(s);
                for(int i = 0; s[i]; ++i){
                    if(s[i] == '$' && !ok1) ok1 = true;
                    else if(s[i] == '{') ok2 = true;
                    else if(s[i] == '$'){
                        ok1 = false;
                        if(!cnt1)  continue;
                        if(cnt1 == 1){
                            if(ans * 2LL > ttt) ok = true;
                            else ans *= 2LL;
                        }
                        else {
                            if(ans * (cnt1+1) > ttt)  ok = true;
                            else  ans *= (cnt1 + 1);
                        }
                        cnt1 = 0;
                    }
                    else if(s[i] == '}'){
                        ok2 = false;
                        if(ans * (cnt2+1) > ttt) ok = true;
                        else ans *= cnt2 + 1;
                        cnt2 = 0;
                    }
                    else if(s[i] == '|' && ok2)  ++cnt2;
                    else if(s[i] == ' ' && ok1)  ++cnt1;
                    else{
                        if(ok1 && cnt1){
                            if(cnt1 == 1){
                                if(ans * 2LL > ttt) ok = true;
                                else ans *= 2LL;
                            }
                            else {
                                if(ans * (cnt1+1) > ttt)  ok = true;
                                else  ans *= (cnt1 + 1);
                            }
                            cnt1 = 0;
                        }
                    }
                }
            }
            if(ok)  puts("doge");
            else printf("%I64d
    ", ans);
        }
        return 0;
    }
    
  • 相关阅读:
    https://blog.csdn.net/nameofcsdn/article/details/53164652
    洛谷
    模板
    模板
    Gym 101911E "Painting the Fence"(线段树区间更新+双端队列)
    Gym 101911F “Tickets”
    图论:最小瓶颈生成树
    图论:次小生成树
    图论:费用流-SPFA+EK
    图论:Dinic算法
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/6014124.html
Copyright © 2020-2023  润新知