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

            啟發:人是怎么算的,就讓程序怎么算,一步一步推。
            #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 閱讀(224) 評論(0)  編輯 收藏 引用 所屬分類: 規律
            <2011年4月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            欧洲国产伦久久久久久久| 午夜天堂精品久久久久| 久久99国产精品久久久| 国产毛片久久久久久国产毛片 | 日本人妻丰满熟妇久久久久久| 性欧美丰满熟妇XXXX性久久久| 国产精品女同久久久久电影院| 久久精品亚洲精品国产欧美| 中文精品久久久久人妻不卡| 精品久久久久久无码国产| 麻豆亚洲AV永久无码精品久久| 亚洲国产精品一区二区久久| 2021久久精品免费观看| 久久亚洲精品中文字幕三区| 久久免费看黄a级毛片| 久久99精品久久久久久不卡| 久久精品中文闷骚内射| 国产欧美久久久精品影院| segui久久国产精品| 久久久国产乱子伦精品作者| 日本加勒比久久精品| 9999国产精品欧美久久久久久| 老色鬼久久亚洲AV综合| 欧美日韩精品久久久免费观看| 亚洲一区二区三区日本久久九| 亚洲人成伊人成综合网久久久| 久久精品无码一区二区三区日韩| 久久r热这里有精品视频| 人妻少妇久久中文字幕 | 亚洲伊人久久综合中文成人网| 久久精品国产精品亚洲精品| 亚洲精品国精品久久99热一| 中文字幕久久亚洲一区| 亚洲伊人久久综合影院| 久久久黄片| 亚洲精品tv久久久久| 亚洲&#228;v永久无码精品天堂久久 | www.久久精品| 久久人人爽人人爽人人AV| 亚洲国产精品无码久久98| 成人久久免费网站|