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

            Xiaoming has just come up with a new way for encryption, by calculating the key from a publicly viewable number in the following way:
            Let the public key N = AB, where 1 <= A, B <= 1000000, and a0, a1, a2, …, ak-1 be the factors of N, then the private key M is calculated by summing the cube of number of factors of all ais. For example, if A is 2 and B is 3, then N = AB = 8, a0 = 1, a1 = 2, a2 = 4, a3 = 8, so the value of M is 1 + 8 + 27 + 64 = 100.
            However, contrary to what Xiaoming believes, this encryption scheme is extremely vulnerable. Can you write a program to prove it?

            Input

            There are multiple test cases in the input file. Each test case starts with two integers A, and B. (1 <= A, B <= 1000000). Input ends with End-of-File.
            Note: There are about 50000 test cases in the input file. Please optimize your algorithm to ensure that it can finish within the given time limit.

            Output

            For each test case, output the value of M (mod 10007) in the format as indicated in the sample output.

            Sample Input

            2 2
            1 1
            4 7

            Sample Output

            Case 1: 36
            Case 2: 1
            Case 3: 4393


            Author: 2008 Asia Hangzhou Regional Contest Online
            這道題是杭州賽區(qū)的網(wǎng)絡(luò)預(yù)選賽的賽題,當(dāng)時打死也沒過,現(xiàn)在也沒有當(dāng)時的代碼了,不知道哪里錯了,今天一看想起了一個公式就是
            1^3+2^3+……n^3=(n)^2*(n+1)*^2/4;記得這個公式還是高二老師教會的著,具體證明我們可以數(shù)學(xué)歸納法證明一下,簡單的很自己證明吧!
            而那時自己網(wǎng)絡(luò)賽的時候不知道怎么推導(dǎo)出過10007是個循環(huán),可以把b的取模,而現(xiàn)在有了這個公式就可以一步搞定為什么對b取模!
            要解題就必須求出a ^b的因子數(shù),這不是難點(diǎn)
            證明如下:
            N=a1^b1*a2^b2*……*aN^bN;根據(jù)排列組合原理我們知道N的因子數(shù)可以如下解出:
            即(b1+1)*(b2+1)*.......*(bN+1);而現(xiàn)在是a^b只需要把(b1*b+1)*(b2*b+1)*.......*(bN*b+1);極為因子數(shù):
            而這個時候我們知道1<=a,b<=1000000超出整形范圍:我們進(jìn)一步優(yōu)化得到
            因?yàn)橛校簃*n%x=(m%x*n%x);(m+n)%x=(m%x+n%x);
            所以我們必須在過程中優(yōu)化算法!
            這樣這道題目就出來了!當(dāng)然求因子時必不可少素數(shù)打表!可以優(yōu)化打表1000,減少時間!當(dāng)然還可以把1-10007的密碼表打出,更優(yōu)時間啊
            素數(shù)打表代碼如下:
            memset(prim,0,sizeof(prim));
            ????
            for(sign=0,i=2;i<MAXN;i++)
            ????????
            if(!prim[i]){
            ????????????num[sign
            ++]=i;
            ????????????
            for(j=0;i*j<MAXN;j++)
            ????????????????prim[i
            *j]=true;????
            ????????}



            posted on 2009-03-23 19:20 KNIGHT 閱讀(520) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            九九久久99综合一区二区| 好久久免费视频高清| 性高朝久久久久久久久久| 久久精品国产亚洲Aⅴ蜜臀色欲| 国产精品99久久不卡| 亚洲国产一成久久精品国产成人综合| 久久久久久久久久久免费精品| 一本一本久久a久久精品综合麻豆| 亚洲成色WWW久久网站| 精品久久久久久无码人妻热 | 久久人妻AV中文字幕| 无码专区久久综合久中文字幕 | 久久精品综合一区二区三区| 欧美一区二区久久精品| 久久99国产综合精品| 国产精品一区二区久久精品涩爱| 久久99毛片免费观看不卡| 久久亚洲AV无码精品色午夜| 国内精品久久久久久不卡影院| 无码人妻久久久一区二区三区| 女同久久| 精品久久综合1区2区3区激情| 国内精品久久久久影院一蜜桃| 欧美久久久久久午夜精品| 99久久精品免费| 99久久精品毛片免费播放| 久久精品国产男包| 伊人久久大香线蕉综合热线| 久久精品国产一区二区| 久久精品成人欧美大片| 2020最新久久久视精品爱 | 久久九九免费高清视频| 久久精品国内一区二区三区| 久久精品国产亚洲AV电影 | 久久精品www人人爽人人| 中文无码久久精品| 狠狠色狠狠色综合久久| 亚洲中文字幕无码久久综合网| 成人午夜精品无码区久久| 国产香蕉久久精品综合网| 老男人久久青草av高清|