• <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 閱讀(113) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            <2009年2月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            欧美日韩成人精品久久久免费看| 97久久国产露脸精品国产 | 久久国产V一级毛多内射| 久久精品国产精品亚洲艾草网美妙| 久久亚洲色一区二区三区| 97精品依人久久久大香线蕉97| 国产成人久久精品激情| 色综合合久久天天给综看| 精品久久久久香蕉网| 亚洲精品视频久久久| 91精品国产色综合久久| 久久中文字幕人妻丝袜| 久久综合狠狠综合久久激情 | 国产69精品久久久久APP下载| segui久久国产精品| 精品久久久久久无码专区不卡| 亚洲色欲久久久久综合网| 亚洲欧美日韩精品久久| av国内精品久久久久影院| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 久久久精品午夜免费不卡| 99久久综合国产精品免费| 国产精品伊人久久伊人电影| 人妻精品久久久久中文字幕一冢本| 亚洲AⅤ优女AV综合久久久| 国产综合精品久久亚洲| 91精品无码久久久久久五月天| 久久国产热精品波多野结衣AV| 久久精品一区二区三区AV| 综合久久一区二区三区 | 久久人妻AV中文字幕| 一日本道伊人久久综合影| 色综合久久天天综线观看| 天天做夜夜做久久做狠狠| 亚洲精品国精品久久99热| 久久精品中文字幕大胸| 国内精品伊人久久久影院| 亚洲中文字幕无码久久2020| 欧美一区二区三区久久综合 | 久久精品国产男包| 久久91精品国产91|