• <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>
            posts - 74,  comments - 33,  trackbacks - 0
            The Embarrassed Cryptographer
            Time Limit: 2000MS Memory Limit: 65536K
            Total Submissions: 4062 Accepted: 804

            Description

            The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys are created from the product of two primes, and are believed to be secure because there is no known method for factoring such a product effectively.
            What Odd Even did not think of, was that both factors in a key should be large, not just their product. It is now possible that some of the users of the system have weak keys. In a desperate attempt not to be fired, Odd Even secretly goes through all the users keys, to check if they are strong enough. He uses his very poweful Atari, and is especially careful when checking his boss' key.

            Input

            The input consists of no more than 20 test cases. Each test case is a line with the integers 4 <= K <= 10100 and 2 <= L <= 106. K is the key itself, a product of two primes. L is the wanted minimum size of the factors in the key. The input set is terminated by a case where K = 0 and L = 0.

            Output

            For each number K, if one of its factors are strictly less than the required L, your program should output "BAD p", where p is the smallest factor in K. Otherwise, it should output "GOOD". Cases should be separated by a line-break.

            Sample Input

            143 10
            143 20
            667 20
            667 30
            2573 30
            2573 40
            0 0

            Sample Output

            GOOD
            BAD 11
            GOOD
            BAD 23
            GOOD
            BAD 31
             
            題目的大意是:給一個很大的數K,和一個普通的整數L,問K有沒有小于L的質因子,有則輸出“BAD 那個因子”,否則輸出“GOOD”。
            首先,明顯當然要打一個素數表了。
            接下來就是關鍵部分了,讀入K,把K轉成千進制。把數字往大進制轉換能夠加快運算效率。千進制的性質與十進制相似。例如,1234567890轉成千進制,就變成了:[1][234][567][890]。

            然后再從小到大枚舉每一個素數,并對其進行高精度求余就行了。
            下面是關鍵部分的一些代碼:
            int divide(int div) //高精度求余。 
            {
                int i,ans=0;
                for(i=la-1;i>=0;i--)
                    ans=(ans*1000+a[i])%div;
                return ans;    
            }

            void makeprime() //建立素數表。 
            {
                int i,j,isprime,k,p=3;
                for(i=6;i<N;i++)
                {
                    isprime=1;
                    k=(int)sqrt(i);    
                    for(j=0;j<p;j++)
                    {
                        if(prime[j]>k+1)
                            break;
                        if(i%prime[j]==0)
                        {
                            isprime=0;
                            break;
                        }    
                    }
                    if(isprime) prime[p++]=i;    
                }    
            }

                    len=strlen(s);
                    for(i=0;i<len;i++) //轉化為千進制。 
                    {
                        t=(len-i+2)/3-1;
                        a[t]=a[t]*10+s[i]-'0';
                    }
                    la=(len+2)/3;
            posted on 2008-12-24 21:51 KNIGHT 閱讀(335) 評論(0)  編輯 收藏 引用
            <2009年4月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品无码一区二区日韩AV| 亚洲性久久久影院| 久久人爽人人爽人人片AV | 日韩乱码人妻无码中文字幕久久 | 国产精品99久久免费观看| 久久香蕉一级毛片| 欧美久久天天综合香蕉伊| 亚洲AV无码1区2区久久| 日韩电影久久久被窝网| 久久99精品国产自在现线小黄鸭| 久久嫩草影院免费看夜色| 国产亚洲精久久久久久无码| 色婷婷噜噜久久国产精品12p | 精品国产99久久久久久麻豆 | 99久久国产热无码精品免费久久久久| 要久久爱在线免费观看| 国产成人久久777777| 日韩人妻无码一区二区三区久久| 久久这里只有精品视频99| 精品综合久久久久久97超人| 亚洲精品乱码久久久久久按摩| 亚洲精品第一综合99久久| 久久精品成人免费观看97| 97热久久免费频精品99| 老色鬼久久亚洲AV综合| 国产精品99久久久久久宅男小说| 久久精品免费网站网| 久久久精品波多野结衣| 国产亚洲成人久久| 久久综合狠狠色综合伊人| 国产一级持黄大片99久久| 漂亮人妻被黑人久久精品| 亚洲AV无码久久精品成人| 亚洲va久久久噜噜噜久久男同| 久久久久久午夜精品| 久久精品国产亚洲av麻豆图片| 久久亚洲熟女cc98cm| 亚洲精品无码久久久久久| 国产麻豆精品久久一二三| 亚洲国产精品久久久久| 久久久久国色AV免费看图片|