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

            zoj3647

            像我這種弱比,十一不能回家,中秋不能回家的弱比,才會在這里默默的刷題,我擦

            昨天zoj月賽,坑死爹了


            ZOJ Problem Set - 3647
            Gao the Grid
            Time Limit: 2 Seconds Memory Limit: 65536 KB

            A n * m grid as follow:




            Count the number of triangles, three of whose vertice must be grid-points.
            Note that the three vertice of the triangle must not be in a line(the right picture is not a triangle).


            Input

            The input consists of several cases. Each case consists of two positive integers n and m (1 ≤ n, m ≤ 1000).
            Output

            For each case, output the total number of triangle.
            Sample Input
            1 1
            2 2
            Sample Output
            4
            76
            hint

            hint for 2nd case: C(9, 3) - 8 = 76


            yy出了想法,想法有些問題,還有搞的重復了好多

            然后今天看了woshi250hua大牛的解題報告,修改了代碼


            然后自認為沒錯了,還是一直wa,

            然后我就改了改輸出 %I64d  ->%lld 

            就過了,坑爹啊

            中秋節木有妹子陪,也木有月餅吃,哎。。??啾频娜兆?/p>


            #include <cstdio>
            #include 
            <cstdlib>
            #include 
            <cstring>
            #include 
            <cmath>
            #include 
            <ctime>
            #include 
            <cassert>
            #include 
            <iostream>
            #include 
            <sstream>
            #include 
            <fstream>
            #include 
            <map>
            #include 
            <set>
            #include 
            <vector>
            #include 
            <queue>
            #include 
            <algorithm>
            #include 
            <iomanip>
            #define maxn 1010
            #define LL long long
            using namespace std;
            LL f[maxn][maxn];
            LL num[maxn];
            LL totpoint,sum;
            LL n,m;
            int gcd(int a,int b)
            {
                
            if(b==0return a;
                
            else return gcd(b,a%b);
            }
            void work()
            {
                memset(num,
            0,sizeof(num));
                num[
            0]=num[1]=num[2]=0;
                
            for(int i=3; i<=1002; i++)
                    
            if(i-1&&i-2)
                        num[i] 
            = i * (i - 1* (i - 2/ 6;
            }
            int main()
            {
                memset(f,
            0,sizeof(f));
                
            for(int i=1; i<=1002; i++)
                {
                    
            for(int j=1; j<=1002; j++)
                        f[i][j]
            =gcd(i,j)-1;
                }
                work();
                
            while(scanf("%I64d%I64d",&n,&m)!=EOF)
                {

                    totpoint
            = (n+1* (m+1);
                    sum 
            = totpoint * ( totpoint - 1 ) * (totpoint - 2/ 6 ;

                    sum 
            -= (m+1)*(num[n+1]);
                    sum 
            -= (n+1)*(num[m+1]);
                    
            for(int i=1;i<=n;i++)
                    
            for(int j=1;j<=m;j++)
                    {
                       sum 
            -=  f[i][j]*(n+1-i)*(m+1-j)*2;
                    }
                    printf(
            "%lld\n",sum);
                }
                
            return 0;
            }


            posted on 2012-09-30 09:42 jh818012 閱讀(165) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            国产精品va久久久久久久| 噜噜噜色噜噜噜久久| 伊人久久大香线蕉AV一区二区| 久久综合九色综合久99| 9191精品国产免费久久| 精品综合久久久久久88小说| 尹人香蕉久久99天天拍| 囯产精品久久久久久久久蜜桃 | 久久综合亚洲色一区二区三区| 99久久精品国产免看国产一区| 国产精品无码久久久久久| 国产精品毛片久久久久久久| 久久精品免费网站网| 久久人人爽人人爽人人AV| 国产毛片久久久久久国产毛片| 亚洲熟妇无码另类久久久| 久久久无码精品午夜| 久久91精品国产91久久小草| 一个色综合久久| 国产精品九九久久免费视频 | jizzjizz国产精品久久| 精品久久久久久国产三级| 精品国产VA久久久久久久冰 | 久久精品国产只有精品66| 99久久免费国产精精品| 精品伊人久久大线蕉色首页| 国产精品久久久久久久久久免费| 亚洲精品午夜国产VA久久成人| 午夜精品久久久久久久无码| 丁香五月综合久久激情| 91精品无码久久久久久五月天 | 久久婷婷激情综合色综合俺也去 | 精品久久久噜噜噜久久久| 久久午夜福利无码1000合集| 欧美伊人久久大香线蕉综合69| 国产精自产拍久久久久久蜜| 久久精品国产一区二区三区日韩| 国产精品无码久久综合| 久久久中文字幕| 国内精品久久久久久久coent| 93精91精品国产综合久久香蕉|