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

            poj1426

            Find The Multiple

            Time Limit: 1000MS Memory Limit: 10000K
            Total Submissions: 10685 Accepted: 4404 Special Judge

            Description

            Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100 decimal digits.

            Input

            The input file may contain multiple test cases. Each line contains a value of n (1 <= n <= 200). A line containing a zero terminates the input.

            Output

            For each value of n in the input print a line containing the corresponding value of m. The decimal representation of m must not contain more than 100 digits. If there are multiple solutions for a given value of n, any one of them is acceptable.

            Sample Input

            2
            6
            19
            0

            Sample Output

            10
            100100100100100100
            111111111111111111
            沒有仔細(xì)分析題目,我一看最后的output不會(huì)超過100位,我就在想怎么存呢
            想了好久也沒想出好方法,如果數(shù)組存的話,可能會(huì)超內(nèi)存,判斷也可能會(huì)超時(shí),最后現(xiàn)不到好辦法
            我還想要不要用double存,然后只是判斷麻煩一些而以,
            結(jié)果去網(wǎng)上找題解發(fā)現(xiàn),只要longlong就能出正解
            呃……我是沙茶
            還有隊(duì)列開了好大,要定義成全局變量
             1#include<stdio.h>
             2#include<string.h>
             3#include<math.h>
             4int n;
             5long long now,q[1000000];
             6void bfs()
             7{
             8    int head,tail;
             9    head=0;
            10    tail=1;
            11    q[tail]=1;
            12    while(head<tail)
            13    {
            14        head++;
            15        now=q[head];
            16        now=now*10;
            17        if(now%n==0)
            18        {
            19            break;
            20        }

            21        tail++;
            22        q[tail]=now;
            23        tail++;
            24        q[tail]=now+1;
            25    }

            26    printf("%I64d\n",now);
            27}

            28int main()
            29{
            30    while(scanf("%d",&n)!=EOF&&n!=0)
            31    {
            32        bfs();
            33    }

            34    return 0;
            35}

            36

            posted on 2012-03-15 19:05 jh818012 閱讀(633) 評(píng)論(2)  編輯 收藏 引用

            評(píng)論

            # re: poj1426 2012-04-02 14:08 王私江

            17 if(now%n==0)
            18 {
            19 break;
            20 }
            你這里判斷明顯慢了很多啊,在下面判斷now*10和now*10+1這樣要快很多。  回復(fù)  更多評(píng)論   

            # re: poj1426 2012-09-20 20:13 season

            我嚓,,輝哥,,居然搜到你的題解了  回復(fù)  更多評(píng)論   


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


            <2012年4月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評(píng)論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當(dāng)于是 取余3的意思 因?yàn)?3 的 二進(jìn)制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
            • --王私江
            久久精品桃花综合| 久久夜色精品国产噜噜麻豆| 久久免费观看视频| 国产成人综合久久精品红| 久久久久亚洲AV片无码下载蜜桃 | 亚洲国产精品无码久久久久久曰| 久久久久久久久久免免费精品 | 国产精品久久久久国产A级| 国产午夜精品理论片久久影视| 成人午夜精品久久久久久久小说| 国内精品伊人久久久影院| 91精品国产91久久久久福利| 欧美性大战久久久久久| 99久久精品费精品国产一区二区 | 久久成人国产精品二三区| 色青青草原桃花久久综合| 亚洲国产精久久久久久久| 久久久这里只有精品加勒比| 久久精品成人免费国产片小草 | 狠狠色噜噜狠狠狠狠狠色综合久久| 手机看片久久高清国产日韩| 久久免费高清视频| 久久综合九色综合97_久久久| 中文字幕无码免费久久| 2020久久精品亚洲热综合一本| 久久国产成人亚洲精品影院| 99久久综合国产精品二区| 国产精品久久久久久福利69堂| 亚洲AV日韩精品久久久久久久| 国产成人综合久久精品红| 国产精品成人久久久| 色偷偷91久久综合噜噜噜噜| 久久se这里只有精品| 精品久久久久久国产牛牛app| 久久免费国产精品一区二区| 国产欧美久久一区二区| 97久久精品人人澡人人爽| 亚洲国产精品久久| 久久久久亚洲?V成人无码| 欧美午夜A∨大片久久| 久久亚洲AV无码精品色午夜麻豆 |