The Great Pan——模拟

The Great Pan
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

As a programming contest addict, Waybl is always happy to take part in various competitive programming contests. One day, he was competing at a regional contest of Inventing Crappy Problems Contest(ICPC). He tried really hard to solve a "geometry" task without success. 

After the contest, he found that the problem statement is ambiguous! He immediately complained to jury. But problem setter, the Great Pan, told him "There are only four possibilities, why don't you just try all of them and get Accepted?". 

Waybl was really shocked. It is the first time he learned that enumerating problem statement is as useful as trying to solve some ternary search problem by enumerating a subset of possible angle! 

Three years later, while chatting with Ceybl, Waybl was told that some problem "setters" (yeah, other than the Great Pan) could even change the whole problem 30 minutes before the contest end! He was again shocked. 

Now, for a given problem statement, Waybl wants to know how many ways there are to understand it. 

A problem statement contains only newlines and printable ASCII characters (32 ≤ their ASCII code ≤ 127) except '{', '}', '|' and '$'. 

Waybl has already marked all ambiguity in the following two formats: 

1.{A|B|C|D|...} indicates this part could be understand as A or B or C or D or .... 
2.$blah blah$ indicates this part is printed in proportional fonts, it is impossible to determine how many space characters there are. 

Note that A, B, C, D won't be duplicate, but could be empty. (indicate evil problem setters addedclarified it later.) 

Also note that N consecutive spaces lead to N+1 different ways of understanding, not 2  N ways. 

It is impossible to escape from "$$" and "{}" markups even with newlines. There won't be nested markups, i.e. something like "${A|B}$" or "{$A$|B}" or "{{A|B}|C}" is prohibited. All markups will be properly matched.
 

Input

Input contains several test cases, please process till EOF. 
For each test case, the first line contains an integer n, indicating the line count of this statement. Next n lines is the problem statement. 
1 ≤ n ≤ 1000, size of the input file will not exceed 1024KB.
 

Output

For each test case print the number of ways to understand this statement, or "doge" if your answer is more than  105.
 

Sample Input

     
     
9 I'll shoot the magic arrow several times on the ground, and of course the arrow will leave some holes on the ground. When you connect three holes with three line segments, you may get a triangle. {|It is hole! Common sense!| No Response, Read Problem Statement|don't you know what a triangle is?} 1 Case $1: = >$ 5 $/*This is my code printed in proportional font, isn't it cool?*/ printf("Definitely it is cooooooool \ %d\n",4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4);$ 2 $Two space$ and {blue| red} color!
 

Sample Output

     
     
4 4 doge 6

这是一道大模拟,输入一个n,下面输出n行,每一行以回车结束,在这个字符串中,有‘{}’,‘$$’两种括号,‘{}’之间以‘|’间隔,每多一个‘|’,计数器加一,‘$$’之间以空格间隔,每多一个空格,计数器加一,但是‘$$’之间如果有其它字符,则空格被隔开。例如:{aj | kd | fg |}aks$    fgh    safd  $;则该字符串输出的结果应该是:4*9。

注意,括号没有交叉。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include<set>

using namespace std;

char a[2123456];

int main()
{
    long long i,j,k,n,u,m,t;
    int f1,f2;
    while(scanf(" %I64d ",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        for(i = 0;i < n;i++)
        {
            gets(a+strlen(a));
        }
        f1 = f2 = 0;
        u = 1;
        m = 1;
        for(i = 0;a[i]!=0;i++)
        {
            if(a[i] == '{')
                {
                    f1 = 1;
                    j = 1;
                }
            if(a[i] == '}')
            {
                f1 = 0;
                m = m * j;
            }
            if(a[i] == '|' && f1 == 1)
            {
                j++;
            }
            if(f2 == 1 && a[i] != ' ' && a[i-1] == ' ')
            {
                m = m * u;
                u = 1;
            }
            if(a[i] == '$')
            {
                if(f2 == 0)
                    f2 = 1;
                else if(f2 == 1)
                    f2 = 0;
                    u = 1;
            }
            if(a[i] == ' ' && f2 == 1)
                u++;
            if(m > 100000)
                break;
        }
        if(m > 100000)
            printf("doge\n");
        else
            printf("%lld\n",m);
    }
    return 0;
}


好的,让我们来模拟一个共享书店的例子,并使用静态成员来实现。 首先,我们需要一个`Book`类表示书籍,其中包括书名和作者: ```cpp class Book { public: Book(string title, string author) : title_(title), author_(author) {} string getTitle() const { return title_; } string getAuthor() const { return author_; } private: string title_; string author_; }; ``` 接下来,我们需要一个`Bookstore`类来表示书店。我们将使用静态成员变量来存储所有书籍的列表。每当有新书加入或旧书出售时,这个列表都会被更新。 ```cpp class Bookstore { public: static void addBook(const Book& book) { books_.push_back(book); } static void sellBook(const Book& book) { for (auto it = books_.begin(); it != books_.end(); ++it) { if (it->getTitle() == book.getTitle() && it->getAuthor() == book.getAuthor()) { books_.erase(it); break; } } } static void printBooks() { cout << "Books in stock:" << endl; for (const auto& book : books_) { cout << book.getTitle() << " by " << book.getAuthor() << endl; } } private: static vector<Book> books_; }; vector<Book> Bookstore::books_; ``` 在这个例子中,`books_`是一个静态成员变量,它是一个`vector`,存储所有在书店中的书籍。 现在我们可以使用`Bookstore`类来添加、出售和打印书籍。下面是一个例子: ```cpp int main() { Bookstore::addBook(Book("The Great Gatsby", "F. Scott Fitzgerald")); Bookstore::addBook(Book("To Kill a Mockingbird", "Harper Lee")); Bookstore::addBook(Book("1984", "George Orwell")); Bookstore::printBooks(); Bookstore::sellBook(Book("To Kill a Mockingbird", "Harper Lee")); Bookstore::printBooks(); return 0; } ``` 输出: ``` Books in stock: The Great Gatsby by F. Scott Fitzgerald To Kill a Mockingbird by Harper Lee 1984 by George Orwell Books in stock: The Great Gatsby by F. Scott Fitzgerald 1984 by George Orwell ``` 可以看到,我们成功地使用了静态成员变量来存储所有书籍的列表,并在添加和出售书籍时更新了它。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值