• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 74,  comments - 33,  trackbacks - 0
            ?
            Time Limit: 1000MS Memory Limit: 30000K
            Total Submissions: 1651 Accepted: 585

            Description

            FJ has a new rule about the cows lining up for dinner. Not only must the N (3 <= N <= 15) cows line up for dinner in order, but they must place a napkin between each pair of cows with a "+", "-", or "." on it. In order to earn their dessert, the cow numbers and the napkins must form a numerical expression that evaluates to 0. The napkin with a "." enables the cows to build bigger numbers. Consider this equation for seven cows:
                  1 - 2 . 3 - 4 . 5 + 6 . 7

            This means 1-23-45+67, which evaluates to 0. You job is to assist the cows in getting dessert. (Note: "... 10 . 11 ...") will use the number 1011 in its calculation.)

            Input

            One line with a single integer, N

            Output

            One line of output for each of the first 20 possible expressions -- then a line with a single integer that is the total number of possible answers. Each expression line has the general format of number, space, napkin, space, number, space, napkin, etc. etc. The output order is lexicographic, with "+" coming before "-" coming before ".". If fewer than 20 expressions can be formed, print all of the expressions.

            Sample Input

            7

            Sample Output

            1 + 2 - 3 + 4 - 5 - 6 + 7
            1 + 2 - 3 - 4 + 5 + 6 - 7
            1 - 2 + 3 + 4 - 5 + 6 - 7
            1 - 2 - 3 - 4 - 5 + 6 + 7
            1 - 2 . 3 + 4 + 5 + 6 + 7
            1 - 2 . 3 - 4 . 5 + 6 . 7
            6
            一個超惡心的題目:
            啥也不說了,就是惡心。
            void?DFS(int?now,int?sign,int?sum){
            ????
            if(sum>10000000)return?;
            ????
            if(now==n){
            ????????
            if(sum1[n]!=0)return?;
            ????????all
            ++;
            ????????
            if(all>20)return?;
            ????????
            for(int?i=1;i<n;i++)
            ????????????printf(
            "%d?%c?",i,flag[i]);
            ????????printf(
            "%d\n",n);
            ????????
            return?;????
            ????}

            ????
            int?i,j,t;
            ????flag[sign]
            ='+';
            ????sum1[sign
            +1]=sum+now+1;
            ????DFS(now
            +1,sign+1,sum1[sign+1]);
            ????flag[sign]
            ='-';
            ????sum1[sign
            +1]=sum-now-1;
            ????DFS(now
            +1,sign+1,sum1[sign+1]);
            ????flag[sign]
            ='.';
            ????
            for(i=sign-1;i>=1;i--)
            ????????
            if(flag[i]!='.')break;
            ????
            if(now>8)t=100*(sum1[sign]-sum1[i])+sum1[i];
            ????
            else?t=10*(sum1[sign]-sum1[i])+sum1[i];
            ????
            if(flag[i]=='+')sum1[sign+1]=t+now+1;
            ????
            else?sum1[sign+1]=t-now-1;
            ????DFS(now
            +1,sign+1,sum1[sign+1]);
            ????
            return?;
            }
            posted on 2009-02-23 21:20 KNIGHT 閱讀(108) 評論(0)  編輯 收藏 引用
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久w5ww成w人免费| 狠狠色婷婷久久综合频道日韩 | 看久久久久久a级毛片| 一本久久a久久精品亚洲| 精品久久久久久久无码| 九九久久精品国产| 久久精品无码一区二区WWW| 久久精品麻豆日日躁夜夜躁| 青青热久久综合网伊人| 一本一本久久A久久综合精品| 99久久99久久| 人妻精品久久久久中文字幕| 日产精品久久久久久久性色| 草草久久久无码国产专区| 久久免费视频1| 久久久久久A亚洲欧洲AV冫| 国产精品久久久亚洲| 久久国产色av免费看| 久久www免费人成精品香蕉| 一本色道久久88精品综合| 香蕉久久永久视频| 国产精品青草久久久久福利99 | 国产精品久久久久…| 国产精品99久久久久久宅男小说| 青青青伊人色综合久久| 99久久国产热无码精品免费| 99精品国产99久久久久久97| 亚洲国产成人久久精品99 | 狠狠狠色丁香婷婷综合久久俺| 亚洲国产婷婷香蕉久久久久久| 97久久综合精品久久久综合| 99精品久久精品一区二区| 中文字幕精品久久| 久久精品中文字幕大胸| 日韩十八禁一区二区久久| 合区精品久久久中文字幕一区| 99久久人人爽亚洲精品美女| 四虎国产永久免费久久| 91精品国产91久久久久久| 日本道色综合久久影院| 精品久久国产一区二区三区香蕉|