• <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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            欧美精品乱码99久久蜜桃| 97久久超碰国产精品2021| 国产巨作麻豆欧美亚洲综合久久| 青青草原综合久久大伊人精品| 国产精品永久久久久久久久久| 怡红院日本一道日本久久 | 久久精品免费观看| 国产三级观看久久| 久久久国产精华液| 精品国产乱码久久久久久浪潮| 久久久久久综合网天天| 国产91久久综合| 奇米影视7777久久精品人人爽| 久久精品视频网| 亚洲欧洲日产国码无码久久99| 久久精品九九亚洲精品天堂| 久久这里只精品99re66| 国产精品美女久久久网AV| 久久综合狠狠综合久久综合88 | 少妇人妻综合久久中文字幕| 久久久精品一区二区三区| 国内精品久久久久影院薰衣草| 精品久久久久久无码国产| avtt天堂网久久精品| 亚洲中文字幕无码久久综合网| 青春久久| 三级三级久久三级久久| 久久精品视屏| 国内精品久久久久久久亚洲| 久久国产精品成人免费| 狠狠色丁香久久综合婷婷| 久久久亚洲欧洲日产国码aⅴ| 精品久久久无码21p发布 | 国产精品久久久99| 久久99免费视频| www亚洲欲色成人久久精品| 免费观看久久精彩视频| 一本久久a久久精品综合夜夜| 91精品婷婷国产综合久久| 91亚洲国产成人久久精品| 大美女久久久久久j久久|