• <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 閱讀(225) 評論(0)  編輯 收藏 引用 所屬分類: 規律
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品国产亚洲AV不卡| 久久精品国产亚洲麻豆| 少妇久久久久久被弄到高潮| 久久久久亚洲精品天堂久久久久久| 久久精品国产日本波多野结衣| 久久亚洲国产成人影院网站| 一本色道久久88综合日韩精品 | 久久国产成人精品麻豆| 亚洲国产精品婷婷久久| 亚洲午夜精品久久久久久浪潮 | 无码乱码观看精品久久| 97精品国产97久久久久久免费| 久久精品国产亚洲77777| 久久WWW免费人成—看片| 午夜不卡久久精品无码免费| 91秦先生久久久久久久| 久久www免费人成看片| 99久久99久久精品国产片果冻| 精品国产99久久久久久麻豆 | 久久久久国色AV免费观看| 久久影院综合精品| 久久一区二区三区99| 久久96国产精品久久久| 一本久久a久久精品亚洲| 久久久久亚洲av成人无码电影 | 精品久久久久久国产牛牛app| 欧洲成人午夜精品无码区久久 | 亚洲精品蜜桃久久久久久| 欧美一级久久久久久久大片| 久久精品天天中文字幕人妻 | 久久午夜福利无码1000合集| 99久久99久久精品国产片| 成人久久综合网| 久久久精品人妻一区二区三区蜜桃| 亚洲国产成人久久一区WWW| 伊人久久大香线蕉精品| 日本免费久久久久久久网站| 国产精品视频久久久| 国产精品久久网| 中文字幕久久欲求不满| 久久99精品久久久久久水蜜桃|