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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            精品国产一区二区三区久久久狼| 国产日韩久久久精品影院首页| 亚洲欧美日韩久久精品| 伊人色综合九久久天天蜜桃| 亚洲午夜无码久久久久| 国产精品久久波多野结衣| 品成人欧美大片久久国产欧美| 日韩精品无码久久一区二区三| 亚洲精品无码久久久久久| 99久久免费国产特黄| 日韩欧美亚洲国产精品字幕久久久| 久久人妻AV中文字幕| 99久久免费只有精品国产| 国内高清久久久久久| 国产精品免费久久久久电影网| 久久久久99这里有精品10| 久久国产乱子精品免费女| 久久国语露脸国产精品电影| 一本大道加勒比久久综合| 欧美丰满熟妇BBB久久久| 美女久久久久久| 精品国产一区二区三区久久| 伊人久久大香线蕉AV色婷婷色| 精品国产乱码久久久久久浪潮| 精品久久久久久成人AV| 久久久精品人妻一区二区三区蜜桃 | 国内精品久久久久久久涩爱| 无码人妻久久一区二区三区| 天天做夜夜做久久做狠狠| 久久线看观看精品香蕉国产| 婷婷五月深深久久精品| 久久综合亚洲色HEZYO国产| 久久精品亚洲福利| 国产午夜电影久久| 久久香蕉国产线看观看99| 久久精品中文騷妇女内射| 少妇高潮惨叫久久久久久 | 亚洲国产成人久久综合野外| 人人狠狠综合久久亚洲88| 久久电影网一区| 国产高潮久久免费观看|