• <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) 評論(0)  編輯 收藏 引用 所屬分類: 規(guī)律
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产成人精品免费久久久久| 国产精品午夜久久| 久久天堂AV综合合色蜜桃网| 99久久精品毛片免费播放| 99久久精品国产一区二区蜜芽 | 精品乱码久久久久久久| 国产精品天天影视久久综合网| 久久99精品国产麻豆不卡| 久久国产精品成人影院| 国产精品久久久久久久午夜片 | 狠狠色丁香婷婷久久综合| 久久久久久夜精品精品免费啦| 国产精品免费看久久久香蕉| 久久人人爽人人爽人人片av麻烦| 久久久久国产精品| 日韩乱码人妻无码中文字幕久久| 国产午夜精品久久久久九九| 欧美精品久久久久久久自慰| 欧美一级久久久久久久大| 久久精品国产99国产精品澳门 | 人妻久久久一区二区三区| 久久99精品国产麻豆不卡| 精品国产福利久久久| 亚洲精品午夜国产VA久久成人| 亚洲国产成人久久综合野外| 日韩精品国产自在久久现线拍| 久久久久亚洲Av无码专| 国内精品久久久久影院薰衣草 | 久久免费视频观看| 一本色道久久HEZYO无码| 99久久做夜夜爱天天做精品| 久久免费大片| 人妻丰满?V无码久久不卡| 久久久99精品成人片中文字幕| 精品国产婷婷久久久| 亚洲午夜久久久精品影院| 久久久久免费精品国产| 久久久九九有精品国产| 国产三级精品久久| 久久激情亚洲精品无码?V| 日韩欧美亚洲国产精品字幕久久久|