zoukankan      html  css  js  c++  java
  • HDU4608+模拟

    简单的模拟题。

    暴力枚举

    /*
    模拟
    */
    #include<algorithm>
    #include<iostream>
    #include<string.h>
    #include<stdlib.h>
    #include<stdio.h>
    #include<math.h>
    #include<queue>
    #include<stack>
    #include<map>
    #include<set>
    using namespace std;
    typedef long long int64;
    //typedef __int64 int64;
    typedef pair<int64,int64> PII;
    #define MP(a,b) make_pair((a),(b)) 
    const int inf = 0x3f3f3f3f;
    const double pi=acos(-1.0);
    const int dx[]={1,-1,0,0};
    const int dy[]={0,0,1,-1};
    const double eps = 1e-8;
    const int maxm = 1005;
    const int maxn = 25;
    
    int num[ maxn ][ maxn ];
    
    int main(){
        //freopen( "in.txt","r",stdin );
        int n;
        while( scanf("%d",&n),n ){
            memset( num,0,sizeof( num ) );
            for( int i=1;i<=n;i++ )
                for( int j=1;j<=n;j++ )
                    scanf("%d",&num[i][j]);
            int cnt = 0;
            int sum = 0;
            int CNT = n;
            for( int loop=1;loop<=(n/2);loop++ ){
                //int x = loop;
                //int y = loop;
                //printf("loop = %d
    ",loop);
                int lux = loop,luy = loop;
                int ldx = loop+CNT-1,ldy = loop;
                int rux = loop,ruy = loop+CNT-1;
                int rdx = loop+CNT-1,rdy = loop+CNT-1;
                int ti = CNT - 1 ;
                int cc = 0;
                int temp_sum = 0;
                int temp_cnt = 0;
                //bool f = false;
                while( cc<ti ){
                    int temp = 0;
                    //if( f==false ){
                    //    f = true;
                    //    ti -- ;
                    //}
                    //printf("(%d,%d) (%d,%d) (%d,%d) (%d,%d)
    ",lux,luy,rux,ruy,ldx,ldy,rdx,rdy);
                    temp = num[lux][luy] + num[rux][ruy] + num[ldx][ldy] + num[rdx][rdy];            
                    if( temp>temp_sum ){
                        temp_sum = temp;
                        temp_cnt = min( cc,ti-cc );
                    }
                    else if( temp==temp_sum ){
                        temp_cnt = min( temp_cnt,min( cc,ti-cc ) );
                    }
                    cc ++ ;
                    luy ++ ;
                    rux ++ ;
                    rdy -- ;
                    ldx -- ;
                }
                CNT -= 2;
                sum += temp_sum;
                cnt += temp_cnt;
            }
            printf("%d %d
    ",sum+num[(n/2)+1][(n/2)+1],cnt);
        }
        return 0;
    }


  • 相关阅读:
    webapp开发绝对定位引发的问题
    git下配置github sshkey
    html5 filereader读取流注意事项
    神奇的负Margin
    泪奔的ie
    第二次作业-实践一 网络攻防环境的搭建
    20199115 2019-2020-2 《网络攻防实践》第一周作业
    《网络攻防实践》寒假作业
    C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
    getline()函数
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3320227.html
Copyright © 2011-2022 走看看