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

            就過了,坑爹啊

            中秋節木有妹子陪,也木有月餅吃,哎。。。苦逼的日子


            #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
            • 評論內容較長,點擊標題查看
            • --王私江
            国产亚洲成人久久| 久久久这里有精品中文字幕| 久久婷婷成人综合色综合| 久久香蕉国产线看观看精品yw| 九九久久精品无码专区| 99久久精品免费看国产| 韩国三级大全久久网站| 热久久国产欧美一区二区精品| 国内精品久久久久久久亚洲| 久久综合给合综合久久| 国产成人无码久久久精品一| 久久―日本道色综合久久| 久久天堂AV综合合色蜜桃网| 伊人久久精品影院| 狠狠色综合网站久久久久久久| 亚洲AV无码久久精品蜜桃| 中文成人无码精品久久久不卡| 久久精品国产亚洲AV大全| 久久夜色精品国产亚洲| 久久亚洲av无码精品浪潮| 狠狠色婷婷综合天天久久丁香| 亚洲午夜久久久影院伊人| 久久久无码精品亚洲日韩京东传媒 | 天天综合久久久网| 久久婷婷久久一区二区三区| 天天爽天天狠久久久综合麻豆| 日韩人妻无码一区二区三区久久99| 亚洲精品乱码久久久久久中文字幕| 中文字幕亚洲综合久久| 亚洲AV日韩精品久久久久久| 国产精品国色综合久久| 久久伊人色| 伊人久久综合热线大杳蕉下载| 国产综合成人久久大片91| 久久久久久精品免费免费自慰| 亚洲欧美国产日韩综合久久| 无码精品久久久久久人妻中字| 久久国产高潮流白浆免费观看| 99re这里只有精品热久久| 四虎影视久久久免费观看| 91久久精品无码一区二区毛片|