• <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 閱讀(225) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 規(guī)律
            <2012年10月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久香综合精品久久伊人| 久久久久18| 精品久久久久久无码不卡| 久久精品三级视频| 66精品综合久久久久久久| 91精品国产91久久久久久青草| 丰满少妇高潮惨叫久久久| 久久精品aⅴ无码中文字字幕重口| 精品久久久中文字幕人妻| 色妞色综合久久夜夜| 久久久久99精品成人片直播| 亚洲AV乱码久久精品蜜桃| 久久无码人妻一区二区三区| 精品久久久久香蕉网| 亚洲国产精品人久久| 久久精品免费大片国产大片| 亚洲成av人片不卡无码久久| 久久久久av无码免费网| 久久国产高潮流白浆免费观看| 77777亚洲午夜久久多喷| 日本道色综合久久影院| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久亚洲国产成人影院| 久久亚洲精品成人无码网站| 久久精品国产清自在天天线| 久久er99热精品一区二区| 国产精品视频久久| 久久一区二区三区免费| 亚洲国产精品18久久久久久| 国产成人无码精品久久久性色 | 久久久久无码精品国产| 精品久久久久久无码中文字幕| 久久精品无码一区二区三区免费 | 国产成人久久激情91| 欧美粉嫩小泬久久久久久久 | 久久人人爽人人爽人人爽| 97久久超碰成人精品网站| 伊人久久大香线蕉综合热线| 久久精品国产亚洲AV无码麻豆| 久久久久香蕉视频| 久久w5ww成w人免费|