• <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 閱讀(111) 評論(0)  編輯 收藏 引用
            <2009年2月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲AV无码久久精品色欲| 久久精品国产亚洲AV蜜臀色欲| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 亚洲va久久久噜噜噜久久| 亚洲欧美成人综合久久久 | 中文字幕无码免费久久| 久久91精品国产91久久小草| 久久精品国产亚洲Aⅴ香蕉| 色综合久久无码五十路人妻| 亚洲一区二区三区日本久久九| 超级碰碰碰碰97久久久久| 国内精品伊人久久久久av一坑 | 欧美牲交A欧牲交aⅴ久久| 久久精品国产一区二区| 国内精品久久九九国产精品| 久久久久无码中| 精品久久久久久久| 久久精品国产亚洲AV无码偷窥| 色8激情欧美成人久久综合电| 国产亚洲精品美女久久久| 99久久夜色精品国产网站| 久久五月精品中文字幕| 久久精品这里热有精品| 精品综合久久久久久97| 久久久精品久久久久久| 青青青国产精品国产精品久久久久| 国产一区二区精品久久岳| 2020国产成人久久精品 | 97久久久精品综合88久久| 91精品国产综合久久四虎久久无码一级| 99精品久久精品一区二区| 久久久久99精品成人片直播| 亚洲中文字幕无码久久2017| 亚洲香蕉网久久综合影视| 99精品久久精品一区二区| 狠狠色婷婷久久综合频道日韩| 久久这里只有精品首页| 狠狠色综合网站久久久久久久高清 | 久久无码人妻一区二区三区 | 91精品久久久久久无码| 久久国产成人|