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

            啟發(fā):人是怎么算的,就讓程序怎么算,一步一步推。
            #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 閱讀(223) 評論(0)  編輯 收藏 引用 所屬分類: 規(guī)律
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            伊人久久大香线蕉综合网站| 久久er热视频在这里精品| 久久婷婷人人澡人人| 中文字幕精品久久久久人妻| 久久国产劲爆AV内射—百度| 久久久噜噜噜久久中文福利| 久久96国产精品久久久| 午夜视频久久久久一区 | …久久精品99久久香蕉国产| 精品一区二区久久久久久久网站| 久久精品夜色噜噜亚洲A∨| 欧美日韩精品久久久久| 蜜桃麻豆www久久| 久久亚洲日韩看片无码| 国产精品无码久久四虎| 国产精品美女久久久久久2018| 婷婷久久综合九色综合98| 久久久久人妻一区二区三区| 久久伊人精品青青草原高清| 亚洲狠狠婷婷综合久久久久| 久久996热精品xxxx| 99久久超碰中文字幕伊人| 99久久国产亚洲综合精品| 国产成人精品综合久久久| 久久人人爽人人爽人人片AV不| 久久亚洲中文字幕精品一区四| 日本道色综合久久影院| 国内精品久久人妻互换| 欧美日韩精品久久免费| 久久综合亚洲色HEZYO社区| 久久精品国产99久久久香蕉| 香蕉久久夜色精品国产小说| 久久久久久狠狠丁香| 国产欧美一区二区久久| 97久久国产亚洲精品超碰热| 久久99热这里只有精品国产| 国产精品久久久久蜜芽| 久久无码中文字幕东京热| 久久99热这里只有精品66| 人人妻久久人人澡人人爽人人精品| 久久久久亚洲av毛片大|