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

            ACM___________________________

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2010年10月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋    

             

            因?yàn)?大于 1 << 16 的和數(shù)都能用 1 -- 1<<16 之間的素?cái)?shù)表示, 不能表示的肯定是 素?cái)?shù)了, 所以處理 1-- 1<<16之間的素?cái)?shù)就可以了.

            不過(guò)貌似這題的數(shù)據(jù)很弱沒(méi)有大于 1 << 16 的素?cái)?shù). 

             

             代碼

            #include <iostream>
            #include <algorithm>
            #include <string>
            #include <set>
            #include <map>
            #include <utility>
            #include <queue>
            #include <stack>
            #include <vector>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <cmath>
            using namespace std;

            struct type
            {
              char name[30];
              int num;
            }a[1005];

            const int MAX_PRIME =  1 << 16;
            # define PRIME_NUM 35000
            int Primes[PRIME_NUM + 10] ;
            bool  PrimeBuffer[MAX_PRIME];
            int _Count = 0;
            int GetPrimes ()
            {
            int i, j ;
            for (i = 2 ; i < MAX_PRIME ; i++)
            {
            if (PrimeBuffer[i] == 0)
            Primes[_Count++] = i ;
            for (j = 0 ; j < _Count && i * Primes[j] <= MAX_PRIME ; j++)
            {
            PrimeBuffer[i * Primes[j]] = 1 ;
              if (i % Primes[j] == 0) break ;
            }
            }
            free (PrimeBuffer) ;
            return _Count ;
            }
            inline bool scan_d(int &num)  //整數(shù)輸入
            {
                    char in;bool IsN=false;
                    in=getchar();
                    if(in==EOF) return false;
                    while(in!='-'&&(in<'0'||in>'9')) in=getchar();
                    if(in=='-'){ IsN=true;num=0;}
                    else num=in-'0';
                    while(in=getchar(),in>='0'&&in<='9'){
                            num*=10,num+=in-'0';
                    }
                    if(IsN) num=-num;
                    return true;
            }
            int main ()
            {
                int T;
                GetPrimes ();
                scan_d(T);
                while ( T -- ) {
                    int N;
                    scan_d( N );
                    int ma = -1;
                    char mi[30] = "{";
                    
                    for ( int i = 0 ; i < N ; ++ i ) {
                          scanf ( "%s",a[i].name);
                          scan_d( a[i].num );
                          int cnt = 0;
                          for ( int j = 0 ; j < _Count && a[i].num > 1 ; ++ j ) {
                                if ( a[i].num%Primes[j]==0 ) {
                                    while(a[i].num%Primes[j]==0)
                                    {
                                       a[i].num /= Primes[j];
                                    }
                                    cnt++;      
                                }
                          }
                          if ( cnt == 0 ) cnt = 1;  // 沒(méi)加這句也能A 說(shuō)明沒(méi)有 1 和 超過(guò)1<<16的素?cái)?shù)
                          if ( ma < cnt ) { ma = cnt; strcpy ( mi, a[i].name ); }
                          else if ( ma == cnt ) { 
                               if ( strcmp ( a[i].name, mi ) < 0 )
                                    strcpy ( mi, a[i].name );     
                          }
                    }
                    puts(mi);
                }
                return 0;
            }

             

            91精品婷婷国产综合久久| 久久久久久久国产免费看| 欧美日韩精品久久久久| 久久综合九色综合网站| 久久夜色精品国产欧美乱| 久久亚洲精品视频| 久久只这里是精品66| 久久久久亚洲精品无码蜜桃 | 久久精品天天中文字幕人妻 | 青青国产成人久久91网| 亚洲国产成人久久综合一区77| 热久久最新网站获取| 国产国产成人精品久久| 久久精品免费全国观看国产| av无码久久久久久不卡网站| 色偷偷88欧美精品久久久| 久久99精品综合国产首页| 久久亚洲sm情趣捆绑调教| 精品乱码久久久久久夜夜嗨 | 久久久国产乱子伦精品作者| 久久久久久国产精品免费免费| 久久天天躁狠狠躁夜夜网站| 国产精品免费久久久久电影网| 久久精品国产99久久无毒不卡| 欧美性大战久久久久久| 97久久国产亚洲精品超碰热| 无码国内精品久久综合88| 久久久久亚洲?V成人无码| 欧美激情精品久久久久| 日韩精品久久无码中文字幕| 思思久久99热只有频精品66| 久久国产精品一区| 国产精品成人无码久久久久久| 久久精品天天中文字幕人妻| 人妻精品久久久久中文字幕69 | 久久国产乱子伦精品免费强| 7777精品久久久大香线蕉| 99久久国产亚洲综合精品| 亚洲人成无码久久电影网站| 亚洲精品国产综合久久一线| 久久久久成人精品无码|