• <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 - 195,  comments - 30,  trackbacks - 0
            Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?

            Sample input

            3
            7
            9901
            

            Output for sample input

            3
            6
            12
            


            可以不用高精度除法,直接如下,很巧妙,不通用。

            #include <stdio.h>
            int main()
            {
            int n, a, b;
            while (EOF != scanf("%d", &n))
            {
            a = 1;
            b = 1;
            while (a)
            {
            a = (a * 10 + 1) % n;
            ++b;
            }
            printf("%d\n", b);
            }
            }

            高精度除法
            ----
            #include<iostream>
            #include<cstdlib>
            using namespace std;
            int a[9]={1,11,111,1111,11111,111111,1111111,11111111,111111111};
            const int MOD=11111;
              bool test(int i,int j)
              {
              if(j<10)
              {
               if(a[j-1]%i==0)
               return true;
               return false;
              }
              else
              {
               int temp=0;
               int k=j%5;
               int p=j/5;
               if(k==0)
               {
                for(int m=1;m<=p;m++)
                   {
                 temp*=100000;
                    temp+=MOD;
                    temp%=i;
                   
                   }
                   if(temp==0)
                   return true;
                   else
                   return false;
                 }
                 else
                 {
                int m,f=1;
                for(m=1;m<=p;m++)
                   {
                    temp*=100000;//由于5位5位除,應當乘上10^5;
                 temp+=MOD;
                    temp%=i;
                   
                   }
                   for(m=0;m<k;m++)//最后應當乘以其后的位數乘10^n,
                   f*=10;
                 if((temp*f+a[k-1])%i==0)
                 return true;
                 else
                 return false;
                 }
               
              }
              }
              int main()
              {
              //freopen("s.txt","r",stdin);
              //freopen("key.txt","w",stdout);
              int i;
              while(cin>>i)
              {
              if(i==1)
              {
               cout<<'1'<<endl;
               continue;
              }
              for(int j=2;;j++)
              {
               if(test(i,j))
               {
                cout<<j<<endl;
                break;
               }
                  }
              }

              //system("PAUSE");
              return   0;
              }

            posted on 2009-07-18 17:38 luis 閱讀(1239) 評論(0)  編輯 收藏 引用 所屬分類: 給我啟發題
            <2010年2月>
            31123456
            78910111213
            14151617181920
            21222324252627
            28123456
            78910111213

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久久黄片| 久久久久亚洲AV无码麻豆| 国产AⅤ精品一区二区三区久久| 国产精品岛国久久久久| 伊人久久综在合线亚洲2019| 伊人久久大香线蕉综合网站 | 久久国产精品一国产精品金尊 | 久久久久成人精品无码中文字幕| 狠狠色丁香久久婷婷综合五月 | 久久久青草久久久青草| 久久伊人五月天论坛| 久久99国产综合精品| 天堂无码久久综合东京热| 久久婷婷五月综合色奶水99啪| 国产精品gz久久久| 久久国产精品99国产精| 久久一区二区免费播放| 久久777国产线看观看精品| 久久综合亚洲色一区二区三区| 秋霞久久国产精品电影院| 精品国产乱码久久久久久人妻| 狠狠精品久久久无码中文字幕| 久久久久人妻一区精品色| 色天使久久综合网天天| 91亚洲国产成人久久精品网址| 久久婷婷五月综合色奶水99啪| 久久九九兔免费精品6| 久久夜色精品国产亚洲av| 成人亚洲欧美久久久久| 国产精品久久自在自线观看| 色偷偷88888欧美精品久久久| 久久久久久久久66精品片| 久久一本综合| 精品久久久一二三区| 亚洲国产天堂久久综合| 欧美日韩精品久久久久| 久久精品这里只有精99品| 99久久精品免费看国产| 国产精品久久久久久久久久免费| 久久99精品国产一区二区三区| 久久国产精品久久|