• <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
            • 評論內容較長,點擊標題查看
            • --王私江
            久久久久久免费视频| 久久精品国产91久久综合麻豆自制| 久久久www免费人成精品| 日日狠狠久久偷偷色综合免费| 精品久久人人妻人人做精品| 久久国产精品免费一区二区三区| 久久久久久毛片免费看| 色天使久久综合网天天| 国内精品久久久久影院薰衣草| 无码人妻少妇久久中文字幕蜜桃 | 国产精品久久成人影院| 久久精品成人| 亚洲午夜久久久久妓女影院 | 久久久免费观成人影院| 久久国产色AV免费观看| 久久伊人精品一区二区三区| 国产成人精品久久亚洲| 无码AV中文字幕久久专区| 久久久久久a亚洲欧洲aⅴ| 久久精品免费大片国产大片| 亚洲va久久久噜噜噜久久| 久久er国产精品免费观看2| 久久久久久午夜精品| 久久久网中文字幕| 精品久久一区二区| 人妻无码αv中文字幕久久| 国内精品久久久久影院老司| 国产精品热久久无码av| 久久亚洲国产精品一区二区| 麻豆精品久久久久久久99蜜桃 | 亚洲国产成人久久综合碰碰动漫3d | 97超级碰碰碰久久久久| 久久久久99这里有精品10| 久久国产视屏| 国产精品无码久久综合网| 久久精品国产亚洲av麻豆色欲| 久久国产AVJUST麻豆| 色8激情欧美成人久久综合电| 久久精品免费网站网| 精品无码人妻久久久久久| 久久精品成人免费观看97|