• <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
            沒有仔細分析題目,我一看最后的output不會超過100位,我就在想怎么存呢
            想了好久也沒想出好方法,如果數組存的話,可能會超內存,判斷也可能會超時,最后現不到好辦法
            我還想要不要用double存,然后只是判斷麻煩一些而以,
            結果去網上找題解發現,只要longlong就能出正解
            呃……我是沙茶
            還有隊列開了好大,要定義成全局變量
             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) 評論(2)  編輯 收藏 引用

            評論

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

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

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

            我嚓,,輝哥,,居然搜到你的題解了  回復  更多評論   

            <2012年9月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            30123456

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            国产成人无码精品久久久性色| 国产一级持黄大片99久久| 人妻丰满?V无码久久不卡| 91麻精品国产91久久久久| 久久精品中文字幕大胸| 久久久久亚洲av无码专区| 精品久久综合1区2区3区激情| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 一本大道久久东京热无码AV| 久久亚洲sm情趣捆绑调教| 精品免费tv久久久久久久| 午夜精品久久久久久影视riav| 亚洲AV无码成人网站久久精品大| 国产精品久久久久久福利漫画 | 久久国产精品无码网站| 性做久久久久久久| 久久精品国产精品亚洲| 2021精品国产综合久久| 东方aⅴ免费观看久久av| Xx性欧美肥妇精品久久久久久| 伊人久久大香线蕉av不变影院| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 女人香蕉久久**毛片精品| 亚洲午夜久久久久妓女影院| 久久强奷乱码老熟女| 久久亚洲高清观看| 久久久久人妻一区精品色| 久久精品一本到99热免费| 欧美一级久久久久久久大| 日韩欧美亚洲综合久久影院d3| 日韩精品久久无码人妻中文字幕| 欧美亚洲国产精品久久久久| 色婷婷久久综合中文久久一本| 99久久99久久精品国产片| 超级碰久久免费公开视频| 久久精品国产99国产电影网 | 国产偷久久久精品专区 | 国产综合成人久久大片91| 久久免费高清视频| 精品国产婷婷久久久| 久久成人永久免费播放|