HDU4891:The Great Pan,hdu4891pan

來源:互聯網
上載者:User

HDU4891:The Great Pan,hdu4891pan
Problem DescriptionAs 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 2N 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. 
InputInput 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. 
OutputFor each test case print the number of ways to understand this statement, or "doge" if your answer is more than 105. 
Sample Input

9I'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?}1Case $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
44doge6
 


題意:理解方法最少油一種,ans = 11.{}內的|個數為n,那麼就是ans*=(n+1)2.$$內的連續空格獨立理解,每有一個連續的n個空格,ans*=(n+1)3.輸出理解方案數,超過100000輸出doge4.{},$$不會有嵌套,所以你也不需要去鑽牛角尖考慮太多,要注意中間過程可能超出int型,我在這裡貢獻了n次WA
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;char str[5000000],s[5000000];int main(){    int n,i,j;    int cnt1,cnt2,flag1,flag2,len;    __int64 sum;    while(scanf("%d",&n)!=EOF)    {        gets(str);        len = 0;        for(i = 0; i<n; i++)        {            gets(str);            int l = strlen(str);            for(j = 0; j<l; j++)            {                s[len] = str[j];                len++;            }        }        flag1 = flag2  = cnt1 = cnt2 = 0;        sum = 1;        for(i = 0; i<len; i++)        {            if(s[i] == '{')                flag1 = 1;            else if(flag1 && s[i] == '|')                cnt1++;            else if(flag1 && s[i] == '}')            {                flag1 = 0;                sum*=(cnt1+1);                cnt1 = 0;            }            else if(s[i] == '$' && flag2 == 0)                flag2 = 1;            else if(s[i] == '$' && flag2 == 1)            {                sum = sum*(cnt2+1);                cnt2 = 0;                flag2 = 0;            }            else if(flag2 && s[i] == ' ')                cnt2++;            else if(flag2 && s[i] != ' ' && s[i]!='$')            {                sum = sum*(cnt2+1);                cnt2 = 0;            }            if(sum>100000)                break;        }        if(sum>100000)            printf("doge\n");        else            printf("%I64d\n",sum);    }    return 0;}




THE GREAT GOD PAN(潘恩大帝)電子書txt全集下載

THE GREAT GOD PAN(潘恩大帝) txt全集小說附件已上傳到百度網盤,點擊免費下載:
免費的,直接下載就行

 
小叮噹:羽翼之謎的片尾曲歌詞,名叫The Great Divide-McClain Sisters QQ郵箱;ayumimimi@qqcom

I never knew I lost you till I found you
找到你前我從未意識到自己曾失去你
And you‘d never guess how close you are to me
你無法想象 你對我來說是多麼親密
Now I want to throw my arms around you
此刻我想擁你入懷
Tell a thousand tales that will astound you
訴說一千個讓你驚奇的故事
Everything about you tells me this was meant to be
你的一切讓我瞭解什麼是命中註定
Don‘t you see?I’m on your side
看到了嗎?我就在你身旁
Les‘t take this ride
讓我們一起前行
And together we‘re facing the world
共同面對這世界
Doing things nobody‘s done before
做前所未有的事
And the great divide
再高大的分界線
Doesn‘t seem so wide
也不再那樣分明
Anymore
無法將你我阻擋
I can‘t recall what life was like without you
我已記不得沒有你相伴的歲月
Now it feels as though we‘ve never been apart
就好像我們從未分離
Tall me every tiny thing about you
告訴我你的一切
Anything you‘ll say l’ll never doubt you
任何你覺得我會懷疑的事
We‘re meant to be together I can feel it in my heart
我打從心底認為我們註定要在一起
It‘s just the start
這隻是開始
I‘m on your side
我在你身旁
Les‘t take this ride
讓我們出發
And together we‘re facing the world
共同面對這世界
Doing things nobody‘s done before
做前所未有的事
And the great divide
再高大的分界線
Doesn‘t seem so wide
也不再那樣分明
And if you‘ll be there beside me when I falter
若我步履蹣跚時有你在身旁
Then whatever comes I know we‘ll take it all in stride
我們便能坦然面對一切
I‘m on your side
我會在你身旁
the great divide
再高大的分界線
It Doesn‘t seem so wide
也不再那樣分明
I‘m on your side
我在你身旁
Les‘t take this ride
讓我們出發
And together we‘re facing the world
共同面對這世界
Doing t......餘下全文>>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.