• <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国产精品久久99| 欧美日韩成人精品久久久免费看| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久国产精品成人免费| 亚洲午夜精品久久久久久人妖| 久久久久四虎国产精品| 日本久久久久久久久久| 亚洲av日韩精品久久久久久a | 97久久久精品综合88久久| 亚洲午夜久久久精品影院| 久久国产劲爆AV内射—百度| 日本精品久久久久中文字幕| 一本久久a久久精品综合香蕉| 久久国产亚洲精品无码| 久久最新免费视频| 久久福利青草精品资源站免费| 久久久久99这里有精品10 | 久久精品国产只有精品66 | 热久久国产欧美一区二区精品| 久久精品亚洲日本波多野结衣 | 久久中文字幕人妻丝袜| 久久精品国产91久久麻豆自制| 欧美国产成人久久精品| 久久久中文字幕日本| 国产91色综合久久免费分享| 亚洲精品乱码久久久久久久久久久久 | 亚洲精品无码久久一线| 久久精品中文字幕一区| 国产农村妇女毛片精品久久| av无码久久久久久不卡网站 | 日日躁夜夜躁狠狠久久AV| 亚洲精品无码久久毛片| 人妻系列无码专区久久五月天| 国产三级观看久久| 国产精品成人无码久久久久久| 亚洲午夜精品久久久久久人妖| 久久免费国产精品一区二区| 久久综合九色综合精品| 99精品伊人久久久大香线蕉| 潮喷大喷水系列无码久久精品|