• <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 - 195,  comments - 30,  trackbacks - 0
            #include <cstdio>
            #include 
            <string>

            int b[51][51][50], N;

            void add ( int i, int j )
            {
                
            int k;
                
            for ( k = 0; k < 50; k ++ )
                    b[i][j][k] 
            = b[i - 1][j - 1][k] + b[i - 1][j][k] * j;
                
            int c = 0, t;
                
            for ( k = 0; k < 50; k ++ )
                
            {
                    t 
            = b[i][j][k] + c;
                    c 
            = t / 10;
                    b[i][j][k] 
            = t % 10;
                }

            }


            void dp ()
            {
                memset ( b, 
            0x00sizeof ( b ) );
                
            int i, j;
                
            for ( i = 1; i <= 50; i ++ )
                
            {
                    b[i][
            1][0= b[i][i][0= 1;
                }

                
            for ( i = 3; i <= 50; i ++ )
                
            {
                    
            for ( j = 2; j < i; j ++ )
                    
            {
                        add ( i, j );
                    }

                }

            }


            void print ( int i, int j )
            {
                
            int k;
                
            for ( k = 49; k >= 0; k -- )
                    
            if ( b[i][j][k] )
                        
            break;
                
            if ( k == -1 )
                    printf ( 
            "0" );
                
            for ( ; k >= 0; k -- )
                    printf ( 
            "%d", b[i][j][k] );
                printf ( 
            " " );
            }


            void print ( int n )
            {
                printf ( 
            "%d ", n );
                
            int i, j, k;
                
            int ans[50];
                memset ( ans, 
            0sizeof ( ans ) );
                
            for ( i = 1; i <= n; i ++ )
                
            {
                    
            for ( j = 0; j < 50; j ++ )
                    
            {
                        ans[j] 
            += b[n][i][j];
                    }

                }

                
            int t, c = 0;
                
            for ( k = 0; k < 50; k ++ )
                
            {
                    t 
            = ans[k] + c;
                    c 
            = t / 10;
                    ans[k] 
            = t % 10;
                }

                
            for ( k = 49; k >= 0; k -- )
                    
            if ( ans[k] )
                        
            break;
                
            if ( k == -1 )
                    printf ( 
            "0" );
                
            for ( ; k >= 0; k -- )
                    printf ( 
            "%d", ans[k] );
                printf ( 
            " " );
            }


            int main ()
            {
                
            //freopen ( "in.txt", "r", stdin );
                dp ();
                
            //print ( 5, 2 );
                while ( scanf ( "%d"&N ) && N )
                
            {
                    print ( N );
                }

                
            return 0;
            }

            Rhyme Schemes
            Status In/Out TIME Limit MEMORY Limit Submit Times Solved Users JUDGE TYPE
            stdin/stdout 3s 8192K 97 55 Special Test

            The rhyme scheme for a poem (or stanza of a longer poem) tells which lines of the poem rhyme with which other lines. For example, a limerick such as

            
            If computers that you build are quantum
            Then spies of all factions will want 'em
            Our codes will all fail
            And they'll read our email
            `Til we've crypto that's quantum and daunt 'em
            Jennifer and Peter Short(http://www.research.att.com/~shor/notapoet.html)
            
            Has a rhyme scheme of aabba, indicating that the first, second and fifth lines rhyme and the third and fourth lines rhyme.

            For a poem or stanza of four lines, there are 15 possible rhyme schemes: aaaa, aaab, aaba, aabb, aabc, abaa, abab, abac, abba, abbb, abbc, abca, abcb, abcc, and abcd.

            Write a program to compute the number of rhyme schemes for a poem or stanza of N lines where N is an input value.

            Input

            Input will consist of a sequence of integers N, one per line, ending with a 0 (zero) to indicate the end of the data. N is the number of lines in a poem.

            Output

            For each input integer N, your program should output the value of N, followed by a space, followed by the number of rhyme schemes for a poem with N lines as a decimal integer with at least 12 correct significant digits (use double precision floating point for your computations).

            Sample Input

            1
            2
            3
            4
            20
            30
            10
            0
            

            Sample Output

            1 1
            2 2
            3 5
            4 15
            20 51724158235372
            30 846749014511809120000000
            10 115975
            


             
            排列組合的題目,大致上從小到大順推即可。設b[i][j]中i表示字符串長度,j表示字符串中用到的字母個數,不難推出b[i][j] = b[i-1][j-1] + b[i - 1][j] * j。
            而我自己的思路一直是想根據最后的那一個字母來推,推不出來

            posted on 2009-05-12 11:42 luis 閱讀(357) 評論(0)  編輯 收藏 引用 所屬分類: 組合數學
            <2012年11月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲国产天堂久久综合网站| 久久99国产精品二区不卡| 久久99精品久久久久久野外| 亚洲国产精品久久久久网站| 久久精品一区二区三区中文字幕| 女人高潮久久久叫人喷水| 久久久久久亚洲精品成人| 欧美精品一本久久男人的天堂| 欧美精品丝袜久久久中文字幕 | 四虎影视久久久免费| 久久中文骚妇内射| 久久久久99精品成人片三人毛片 | 国产精品久久久久9999高清| 久久男人AV资源网站| 国产精品久久久久9999高清| 久久精品青青草原伊人| 国产巨作麻豆欧美亚洲综合久久| 日韩AV无码久久一区二区| 日本国产精品久久| 国产午夜精品久久久久九九| 国产婷婷成人久久Av免费高清 | 国产2021久久精品| 久久久久99精品成人片欧美| 亚洲精品午夜国产va久久| 亚洲综合精品香蕉久久网97 | 色成年激情久久综合| 国产三级久久久精品麻豆三级 | 国产精品乱码久久久久久软件| 91精品婷婷国产综合久久 | 亚洲国产精品久久久久| 久久天天躁狠狠躁夜夜avapp| 久久精品国产乱子伦| 国产精品成人久久久| 亚洲国产成人久久综合野外| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久久老熟女一区二区三区| 伊人热热久久原色播放www| 久久亚洲色一区二区三区| 久久久久亚洲AV无码去区首| 久久久久国产精品麻豆AR影院 | 免费精品久久久久久中文字幕|