• <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
            • 評論內容較長,點擊標題查看
            • --王私江
            久久亚洲AV无码西西人体| 国产精品视频久久久| 色综合合久久天天给综看| 久久久久婷婷| 亚洲国产精品成人久久| 久久久国产精品福利免费| 久久精品国产一区二区三区不卡| 久久婷婷色香五月综合激情| …久久精品99久久香蕉国产 | 久久综合狠狠综合久久激情 | 久久大香香蕉国产| 精品无码久久久久久国产| 久久久亚洲AV波多野结衣| 色综合久久天天综合| 色欲久久久天天天综合网精品| 成人精品一区二区久久| 久久人人爽爽爽人久久久| 久久久精品人妻无码专区不卡 | 国内精品伊人久久久久av一坑| 国内精品久久久久久久涩爱 | 国产AV影片久久久久久 | 久久人人爽人人澡人人高潮AV | 精品国产综合区久久久久久| 色88久久久久高潮综合影院| 久久伊人五月天论坛| 国产精品久久久99| 久久综合丝袜日本网| 久久99精品久久久久久| 久久久久久国产精品免费无码| 国产精品久久久香蕉| 伊人色综合久久天天网| 久久久精品日本一区二区三区| 国产精品99久久久久久董美香| 久久电影网2021| 国产精品久久99| 久久这里只精品国产99热| 国内精品久久九九国产精品| 国产三级久久久精品麻豆三级 | 久久久黄片| 亚洲精品WWW久久久久久| 亚洲欧美日韩久久精品|