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;
    }


  • 相关阅读:
    Analysis Services 查询性能十大最佳实践(转)
    谈谈一年来对“数据仓库”概念的困惑、探索和感悟(转)
    用sql语句添加删除主键
    大文件流操作及编码
    SQL Server CONVERT() 函数
    正则表达式提取案例1
    解析SQL SERVER存储过程返回值
    文件操作类Path
    HTTP状态码
    自己写的遮罩层效果
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3320227.html
Copyright © 2011-2022 走看看