zoukankan      html  css  js  c++  java
  • hash--1264--与前类似

    hdu的为你推荐相关题目 还真TM相关啊...

    这题 又是用hash数组标记来做的 水题啊 明天 有时间的话 随便换换来做

          touch  me

     1 #include <iostream>
     2 #include <cstring>
     3 using namespace std;
     4 
     5 const int size = 105;
     6 int hash[size+5][size+5];
     7 
     8 int main()
     9 {
    10     cin.sync_with_stdio(false);
    11     bool flag = false;
    12     int i , j , a , b , c , d , cnt;
    13     while( cin >> a >> c >> b >> d )
    14     {
    15         cnt = 0;
    16         memset( hash , false , sizeof(hash) );
    17         for( i = min(a,b)+1 ; i<=max(a,b) ; i++ )
    18             for( j = min(c,d)+1 ; j<=max(c,d) ; j++ )
    19                 hash[i][j] = true;
    20         while(1)
    21         {
    22             cin >> a >> c >> b >> d;
    23             if( a==-1 && b==-1 && c ==-1 && d==-1 )
    24                 break;
    25             else if( a==-2 && b==-2 && c==-2 && d==-2 )
    26             {
    27                 flag = true;
    28                 break;
    29             }    
    30             for( int i = min(a,b)+1 ; i<=max(a,b) ; i++ )
    31             {
    32                 for( int j = min(c,d)+1 ; j<=max(c,d) ; j++ )
    33                 {
    34                     if( !hash[i][j] )
    35                         hash[i][j] = true;
    36                 }
    37             }
    38         }
    39         for( int i = 0 ; i<=size ; i++ )
    40         {
    41             for( int j = 0 ; j<=size ; j++ )
    42             {
    43                 if( hash[i][j] )
    44                 {
    45                     cnt++;
    46                 }
    47             }
    48         }
    49         cout << cnt << endl;
    50         if( flag )
    51             break;
    52     }
    53     return 0;
    54 }
    View Code
    just follow your heart
  • 相关阅读:
    8.20 附加赛3
    8.22 附加赛4
    Codeforces Round #505 (Div 1 + Div 2) (A~D)
    8.9 附加赛2
    8.10 正睿暑期集训营 Day7
    8.9 正睿暑期集训营 Day6
    8.8 正睿暑期集训营 Day5
    8.7 正睿暑期集训营 Day4
    8.6 正睿暑期集训营 Day3
    8.5 正睿暑期集训营 Day2
  • 原文地址:https://www.cnblogs.com/radical/p/3872220.html
Copyright © 2011-2022 走看看