• <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>
            我要啦免费统计

             

            /*
                求素?cái)?shù)
                1000W以內(nèi)的素?cái)?shù),27063ms
                100W以內(nèi)的素?cái)?shù),1141ms
                10W以內(nèi)的素?cái)?shù),47ms
              by蔡?hào)|赟于無聊的09.09.22日
            */


            #include
            <iostream>
            #include
            <cstdio>
            #include
            <cstdlib>
            #include
            <assert.h>
            #include
            <ctime>
            #include
            <cmath>
            using namespace std;

            const int MAX = 10000000;
            int findvalue[MAX] = {2};
            int find = 1;


            bool IsPrim(int value)
            {
                assert(value 
            >= 2);

                
            int flag = (int) sqrt((double)value);

                
            if(value == 2
                    
            return true;

                
            for (int i = 0; i < find && i <= flag; i++)
                
            {
                    
            if( (value % findvalue[i]) == 0)
                    
            {
                        
            return false;
                    }

                }


                findvalue[find
            ++= value;
                
            return true;
            }


            int main()
            {
                
            double start,finish;
                start 
            = clock();

                
            for (int j = 3;j < MAX; j++)
                
            {
                    
            if (IsPrim(j))
                    
            {
                        
            //cout << "" << j << endl;
                    }

                }


                finish 
            = clock();

                

                cout 
            << "time:" << (finish - start) << "ms" <<endl;
                system(
            "pause");
                
            return 0;
            }
            posted on 2009-09-22 10:38 閱讀(1724) 評(píng)論(7)  編輯 收藏 引用 所屬分類: algorithm

            評(píng)論:
            # re: 求素?cái)?shù)時(shí)間測(cè)試 2009-09-22 11:47 | abettor
            將已經(jīng)求出的素?cái)?shù)放入一個(gè)數(shù)組,判斷下一個(gè)數(shù)是否為素?cái)?shù)時(shí),讓他去除當(dāng)前已經(jīng)得出的所有素?cái)?shù)。  回復(fù)  更多評(píng)論
              
            # re: 求素?cái)?shù)時(shí)間測(cè)試 2009-09-22 13:18 | 戴爾電腦
            不錯(cuò)?。。。?nbsp; 回復(fù)  更多評(píng)論
              
            # re: 求素?cái)?shù)時(shí)間測(cè)試 2009-09-22 15:34 | cqh
            暈爺還寫這個(gè)啊,看來是在鞏固基礎(chǔ),加油!  回復(fù)  更多評(píng)論
              
            # re: 求素?cái)?shù)時(shí)間測(cè)試[未登錄] 2009-09-23 16:30 | vincent
            orz..用篩選法吧  回復(fù)  更多評(píng)論
              
            # re: 求素?cái)?shù)時(shí)間測(cè)試 2009-09-23 19:25 | cdy20
            @cqh
            我在練規(guī)范 - - ?。?nbsp; 回復(fù)  更多評(píng)論
              
            # re: 求素?cái)?shù)時(shí)間測(cè)試 2009-09-23 21:43 | cdy20
            @vincent
            不是  回復(fù)  更多評(píng)論
              
            # re: 求素?cái)?shù)時(shí)間測(cè)試 2009-09-23 21:44 | cdy20
            @abettor
            是  回復(fù)  更多評(píng)論
              
            欧美亚洲国产精品久久蜜芽 | 欧美与黑人午夜性猛交久久久 | 精品多毛少妇人妻AV免费久久| 日日狠狠久久偷偷色综合0| 色综合久久夜色精品国产| 伊人久久大香线蕉av一区| 99久久人妻无码精品系列蜜桃| 开心久久婷婷综合中文字幕| 欧美丰满熟妇BBB久久久| 狠狠久久综合伊人不卡| 久久综合香蕉国产蜜臀AV| 久久青青草原国产精品免费| 色综合合久久天天给综看| 久久99国内精品自在现线| 久久精品这里只有精99品| 久久国产精品成人影院| 午夜视频久久久久一区| 国产精品99久久不卡| 国产成人精品白浆久久69| 久久经典免费视频| 久久国产香蕉一区精品| 久久久久久久尹人综合网亚洲| 青青草原综合久久大伊人| 久久无码国产| 久久婷婷国产麻豆91天堂| 一本色道久久88—综合亚洲精品| 欧美久久一级内射wwwwww.| 久久久91精品国产一区二区三区 | 一本色道久久综合亚洲精品| 久久亚洲国产成人精品无码区| 91久久香蕉国产熟女线看| 精品国产VA久久久久久久冰 | 久久九九青青国产精品| 精品999久久久久久中文字幕| 久久久久人妻一区精品性色av| 色欲综合久久中文字幕网| 久久天天躁狠狠躁夜夜avapp| 精品国产乱码久久久久软件| 国产毛片欧美毛片久久久| 久久婷婷国产剧情内射白浆| 亚洲午夜久久久久妓女影院|