• <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 - 16,comments - 0,trackbacks - 0
            給出 2n 個數,求最大的 x 滿足 x!%M = 0 ,其中 M = a1^b1*a2^b2*a3^b3…*an^bn 。

            Input

            In the first line is an integer T (1<=T<=50) indicating the number of test cases.
            Each test case begins with an integer n (1<=n<=100), then followed n lines. Each line contains two numbers ai and bi (1 <= ai <= 100, 1<=bi<=10000000000000)

            Output

            For each test case output the result x in one line.

            Source
            2010 Asia Regional Hangzhou Site Online Contest
            #?include?<stdio.h>
            #?include?
            <string.h>
            #?include?
            <math.h>

            #?define?N?
            101
            typedef?
            long?long?int?LL;

            int?n;
            /*******************************************************/
            int?p[50],?top?=?0;
            int?isPrime(int?x)
            {
            ????????????????
            int?i;
            ????????????????
            if?(x%2==0)?return?x==2;
            ????????????????
            if?(x%3==0)?return?x==3;
            ????????????????
            if?(x%5==0)?return?x==5;
            ????????????????
            for?(i?=?7;?i?<?x;?i?+=?5)
            ????????????????????????????????
            if?(x%i?==?0)?return?0;
            ????????????????
            return?1;
            }

            void?pre(void)
            {
            ????????????????
            int?i;
            ????????????????
            for?(i?=?2;?i?<?N;?++i)
            ????????????????????????????????
            if?(isPrime(i))?p[top++]?=?i;
            }
            /*******************************************************/
            LL?pn[
            50];
            void?init(void)
            {
            ????????????????
            int?i,?j,?x;
            ????????????????LL?cnt;
            ????????????????LL?num;
            ????????????????memset(pn,?
            0,?sizeof(pn));
            ????????????????scanf(
            "%d",?&n);
            ????????????????
            for?(i?=?0;?i?<?n;?++i)
            ????????????????{
            ????????????????????????????????scanf(
            "%d%I64d",?&x,?&num);
            ????????????????????????????????
            for?(j?=?0;?j?<?top;?++j)
            ????????????????????????????????{
            ????????????????????????????????????????????????
            if?(x%p[j]?==?0)
            ????????????????????????????????????????????????{
            ????????????????????????????????????????????????????????????????cnt?
            =?0;
            ????????????????????????????????????????????????????????????????
            while?(x%p[j]==0)?++cnt,?x/=p[j];
            ????????????????????????????????????????????????????????????????pn[j]?
            +=?cnt*num;
            ????????????????????????????????????????????????}
            ????????????????????????????????}
            ????????????????}
            }
            LL?Max(LL?x,?LL?y)
            {
            ????????????????
            return?x>y???x:y;
            }

            LL?mypow(
            int?pr,?int?cnt)
            {
            ????????????????LL?ret?
            =?1;
            ????????????????
            while?(cnt?>?0)?--cnt,?ret?*=?pr;
            ????????????????
            return?ret;
            }

            LL?cal(
            int?pr,?LL?tot)
            {
            ????????????????
            int?tmp;
            ????????????????LL?ppow?
            =?0,?temp;
            ????????????????
            while?(tot?>?0)
            ????????????????{
            ????????????????????????????????tmp?
            =?(int)floor(log(tot*(pr-1)+1)/log(pr))+1;
            ????????????????????????????????
            while?((mypow(pr,?tmp)-1)/(pr-1)?>?tot)?--tmp;
            ????????????????????????????????temp?
            =?mypow(pr,?tmp);
            ????????????????????????????????ppow?
            +=?temp;
            ????????????????????????????????tot?
            -=?(temp-1)/(pr-1);
            ????????????????}
            ????????????????
            return?ppow;
            }
            void?solve(void)
            {
            ????????????????
            int?i;
            ????????????????LL?ans?
            =?0;
            ????????????????
            for?(i?=?0;?i?<?top;?++i)?if?(pn[i]?!=?0)
            ????????????????????????????????????????????????ans?
            =?Max(ans,?cal(p[i],?pn[i]));
            ????????????????printf(
            "%I64d\n",?ans);
            }

            int?main()
            {
            ????????????????
            int?T;
            ????????????????pre();
            ????????????????scanf(
            "%d",?&T);
            ????????????????
            while?(T--)?init(),?solve();

            ????????????????
            return?0;
            }

            posted on 2012-09-08 16:01 yajunw 閱讀(182) 評論(0)  編輯 收藏 引用
            欧美伊人久久大香线蕉综合| 久久亚洲日韩精品一区二区三区| 国产69精品久久久久观看软件| 国产成人综合久久久久久| 91久久精品91久久性色| 久久久无码精品亚洲日韩按摩 | 国产—久久香蕉国产线看观看| 久久精品亚洲精品国产色婷| 日韩人妻无码一区二区三区久久| av色综合久久天堂av色综合在| 亚洲愉拍99热成人精品热久久| 少妇人妻综合久久中文字幕| 久久99这里只有精品国产| 精品久久久久久久久免费影院| 波多野结衣AV无码久久一区| 午夜精品久久久久久99热| 狠狠色综合网站久久久久久久高清| 狠狠色狠狠色综合久久| AV色综合久久天堂AV色综合在| 精品久久久久久| 久久精品国产亚洲5555| 久久亚洲AV无码精品色午夜麻豆| 狠狠精品久久久无码中文字幕| 99久久免费国产特黄| 久久99精品久久久久久9蜜桃| 亚洲国产成人乱码精品女人久久久不卡 | 91久久精一区二区三区大全| 一级做a爰片久久毛片人呢| 久久人人超碰精品CAOPOREN | 久久99久久99小草精品免视看| 精品久久人人妻人人做精品| 一级a性色生活片久久无| 精品无码久久久久久尤物| 久久亚洲色一区二区三区| 亚洲精品无码久久久久| 国产精品久久久天天影视香蕉 | 色播久久人人爽人人爽人人片AV| 久久久精品人妻一区二区三区四| 国产免费久久久久久无码| 99久久夜色精品国产网站| 精品久久久久久99人妻|