• <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)論排行榜

            国产69精品久久久久APP下载| 亚洲精品国产美女久久久| 久久国产精品-久久精品| 久久夜色精品国产亚洲| 久久国产乱子伦精品免费午夜| 久久夜色精品国产亚洲| 国产精品美女久久久网AV| 伊色综合久久之综合久久| 99久久精品国产高清一区二区 | 久久综合鬼色88久久精品综合自在自线噜噜| 美女久久久久久| 久久精品国产69国产精品亚洲| 久久久久无码专区亚洲av| 久久精品欧美日韩精品| 久久久久久国产精品美女| 久久精品国产亚洲一区二区三区| 午夜天堂精品久久久久| 超级97碰碰碰碰久久久久最新| 国产成人精品久久一区二区三区av| 无码人妻少妇久久中文字幕蜜桃| 四虎影视久久久免费观看| 精品水蜜桃久久久久久久| 9久久9久久精品| 久久国产精品久久精品国产| 色婷婷综合久久久久中文| 综合人妻久久一区二区精品| 欧美黑人激情性久久| 午夜精品久久久久| 国产精品久久久久久久app| 久久久久久一区国产精品| 久久人妻少妇嫩草AV蜜桃| 狠狠色综合久久久久尤物| 丰满少妇人妻久久久久久4| 久久精品国产一区二区三区日韩| 国产精品久久久久jk制服| 国产精品久久自在自线观看| 久久99国产精品99久久| 色综合久久久久网| 久久久久久极精品久久久| 一97日本道伊人久久综合影院| 久久精品国产精品亚洲精品|