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

            gzwzm06

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              1 隨筆 :: 52 文章 :: 17 評論 :: 0 Trackbacks
              1#include <stdio.h>
              2
              3const int KEY = 149997 ;
              4const int MAXN = 100000 ;
              5
              6struct HashItem
              7{
              8    __int64 len[6] ;
              9    HashItem *next ;
             10    HashItem(){
             11        next = NULL ;
             12    }

             13}
             ;
             14
             15HashItem hash[KEY], g_Temp[MAXN] ;
             16int g_Pos = 0 ;
             17
             18unsigned long l[6] ;
             19
             20void Copy( HashItem *p )
             21{
             22    for ( int i = 0 ; i < 6 ; ++i )
             23        p->len[i] = l[i] ;
             24}

             25
             26bool Judge(HashItem *p)
             27{
             28    int i , j , cnt ;
             29    bool equal ;
             30    for ( i = 0 ; i < 6 ; ++i )
             31    {
             32        cnt = 0 ;
             33        equal = true ;
             34        j = i ;
             35        while ( cnt != 6 )
             36        {
             37            if ( p->len[cnt] != l[j] )
             38            {
             39                equal = false ;
             40                break ;
             41            }

             42            cnt++ ;
             43            j = ( j + 1 ) % 6 ;
             44        }

             45        
             46        if ( equal )
             47            return true ;
             48    }

             49    
             50    for ( i = 0 ; i < 6 ; ++i )
             51    {
             52        cnt = 0 ;
             53        equal = true ;
             54        j = i ;
             55        while ( cnt != 6 )
             56        {
             57            if ( p->len[cnt] != l[j] )
             58            {
             59                equal = false ;
             60                break ;
             61            }

             62            cnt++ ;
             63            j-- ;
             64            if ( j == -1 )
             65                j = 5 ;
             66        }

             67        if ( equal )
             68            return true ;
             69    }

             70    
             71    return false ;
             72    
             73}

             74
             75bool Insert()
             76{
             77    unsigned long value = 0 ;
             78    int i ;
             79    
             80    for ( i = 0 ; i < 6 ; ++i )
             81    {
             82        value += l[i] ;
             83    }

             84    
             85    unsigned int pos = value % KEY ;
             86    
             87    HashItem *ptr = hash[pos].next ;
             88    
             89    while ( ptr )
             90    {
             91        if ( Judge( ptr ) )
             92            return true ;
             93        ptr = ptr->next ;
             94    }

             95    
             96    ptr = &g_Temp[g_Pos++] ;
             97    
             98    Copy( ptr ) ;
             99    ptr->next = hash[pos].next ;
            100    hash[pos].next = ptr ;
            101    
            102    return false ;
            103}

            104
            105int main()
            106{
            107    int n , i ;
            108    bool isSame = false ;
            109    
            110//    freopen("in.txt", "r", stdin) ;
            111    scanf("%d"&n) ;
            112    while ( n-- )
            113    {    
            114        for ( i = 0 ; i < 6 ; ++i )
            115            scanf("%ld"&l[i]) ;
            116        if ( !isSame )
            117        {
            118            isSame = Insert() ;
            119        }

            120        if ( isSame )
            121            break ;
            122    }

            123    
            124    if ( isSame )
            125    {
            126        printf("Twin snowflakes found.\n") ;
            127    }

            128    else {
            129        printf("No two snowflakes are alike.\n") ;
            130    }

            131    
            132    return 0 ;
            133}
            posted on 2008-11-11 00:39 閱讀(309) 評論(0)  編輯 收藏 引用 所屬分類: Hash應用
            亚洲精品乱码久久久久久不卡| 久久综合亚洲色HEZYO国产| 久久青青草原精品影院| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 久久AV无码精品人妻糸列| 久久99热这里只有精品国产| 999久久久免费精品国产| 久久99精品国产自在现线小黄鸭| 亚洲欧洲日产国码无码久久99| 精品国产乱码久久久久软件| 亚洲精品无码久久久影院相关影片 | 综合网日日天干夜夜久久| 久久综合香蕉国产蜜臀AV| 久久99热精品| 久久人人爽人人澡人人高潮AV| 91精品婷婷国产综合久久| 日韩AV毛片精品久久久| av色综合久久天堂av色综合在| 久久只有这里有精品4| 国产成人久久激情91| 久久精品免费一区二区三区| 香港aa三级久久三级| 久久久久国产成人精品亚洲午夜| 国产成人综合久久精品红| 久久精品国产亚洲AV久| 久久精品中文无码资源站| 香港aa三级久久三级老师2021国产三级精品三级在 | 国产欧美一区二区久久| 四虎国产精品免费久久5151| 国产精品青草久久久久福利99 | 久久婷婷五月综合国产尤物app| 99久久无色码中文字幕人妻| 国产V亚洲V天堂无码久久久| 狠狠精品久久久无码中文字幕 | 亚洲国产精品无码久久98| 69久久夜色精品国产69| 亚洲?V乱码久久精品蜜桃| 久久夜色精品国产噜噜麻豆| 久久青青草原亚洲av无码| 久久婷婷五月综合97色| 久久久人妻精品无码一区|