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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            一本色道久久88精品综合 | 久久只有这精品99| 久久久久亚洲AV成人网人人网站 | 久久综合成人网| 青青草原综合久久大伊人导航 | 日韩久久久久久中文人妻| 亚洲精品NV久久久久久久久久| 亚州日韩精品专区久久久| 亚洲欧美一级久久精品| 亚洲欧美日韩精品久久亚洲区| 久久久SS麻豆欧美国产日韩| 久久久久亚洲AV片无码下载蜜桃| 国产精品久久久久jk制服| 99久久精品免费看国产一区二区三区| 久久精品国产福利国产琪琪 | 亚洲国产精品无码久久一线| 国产成人久久AV免费| 久久996热精品xxxx| 国产成人精品久久| 日本精品久久久久中文字幕| 青青草原综合久久大伊人导航| 久久99精品久久久久婷婷| 久久国产成人| 国产综合久久久久| 国产精品美女久久福利网站| 久久精品国产99久久久| 亚洲国产精品成人久久蜜臀 | 久久免费线看线看| 中文字幕日本人妻久久久免费| 久久免费高清视频| 久久av无码专区亚洲av桃花岛| 亚洲人成无码www久久久| 国产亚洲美女精品久久久| 成人综合伊人五月婷久久| 久久久久高潮综合影院| 久久综合狠狠综合久久97色| 日韩精品久久久久久| 久久精品国产亚洲沈樵| 久久精品亚洲中文字幕无码麻豆| 久久精品国产亚洲AV忘忧草18| 一级做a爰片久久毛片毛片|