• <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
            There is chessboard which has N * M squares size of 1 * 1 and small squares can build up to a large one. Can you tell Mr. Guo that how many squares in the chessboard?

            For Example, when N = 2 and M = 3, there are 6 squares size of 1 * 1 and 2 squares size of 2 * 2 in the chessboard, so the answer is 8.

            Input

            There are several lines in the input, each line consist of two positive integers N and M (1 <= N <= 100, 1 <= M <= 100) except the last line which N = 0 and M = 0 implying the end of the input and you should not process it.

            Output

            Please output the number of the squares for each chessboard in a single line.

            Sample Input

            1 1
            2 3
            3 3
            0 0
            

            Sample Output

            1
            8
            14
            

            啟發:人是怎么算的,就讓程序怎么算,一步一步推。
            #include<iostream>
            using namespace std;
            int main()
            {
            int n,m;
            long sum=0;
            int i;
            while(cin>>n>>m,n)
            {
            if(n==m)
            {
            sum=n*(n+1)*(2*n+1)/6;
            cout<<sum<<endl;
            }
            else
            {
            for(i=0;i<n&&i<m;i++)
            sum+=(n-i)*(m-i);
            cout<<sum<<endl;
            }
            sum=0;
            }
            return 0;
            }
            posted on 2009-07-03 16:41 luis 閱讀(225) 評論(0)  編輯 收藏 引用 所屬分類: 規律
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品无码一区二区三区日韩| 99久久无码一区人妻| 久久香综合精品久久伊人| 99久久夜色精品国产网站| 精品久久久久久国产| 一级做a爰片久久毛片毛片| 久久丫精品国产亚洲av不卡| 久久99国产精品久久99果冻传媒| 亚洲欧洲久久av| 久久国产乱子精品免费女| 久久精品免费大片国产大片| 嫩草伊人久久精品少妇AV| 2020最新久久久视精品爱| 看久久久久久a级毛片| 亚洲人成无码www久久久| 欧美精品一本久久男人的天堂| 天堂久久天堂AV色综合| 亚洲国产天堂久久久久久| 久久久青草久久久青草| 久久久久亚洲av无码专区| 四虎国产精品成人免费久久| 狠狠久久综合| 99久久国产综合精品五月天喷水| 久久天堂AV综合合色蜜桃网| 77777亚洲午夜久久多人| 四虎影视久久久免费| 久久国产视频网| 国内精品久久久久久不卡影院| 久久国产免费观看精品3| 亚洲伊人久久精品影院| 久久精品国产色蜜蜜麻豆| 超级97碰碰碰碰久久久久最新| 久久久久久极精品久久久| 久久无码人妻精品一区二区三区| 国产亚洲美女精品久久久| 国内精品久久久久久久涩爱 | 国产精品久久久久久久久软件| 88久久精品无码一区二区毛片 | 久久这里只精品国产99热| 99久久久精品| 国内精品伊人久久久久网站|