• <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 閱讀(1237) 評論(0)  編輯 收藏 引用 所屬分類: 給我啟發題
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品青草久久久久福利99| 久久丫精品国产亚洲av不卡| 久久黄视频| 97香蕉久久夜色精品国产| 奇米影视7777久久精品| 91精品国产高清久久久久久91| 精品久久久久久无码国产| 久久无码AV一区二区三区| 99久久婷婷国产综合亚洲| 久久久国产一区二区三区| 久久精品国产亚洲AV无码娇色 | 久久丝袜精品中文字幕| 久久精品人人做人人爽电影| 国产精品久久久久AV福利动漫| 久久91精品综合国产首页| 99国产欧美精品久久久蜜芽| 亚洲伊人久久成综合人影院 | 久久99国产综合精品| 久久人人爽人人精品视频| 久久超碰97人人做人人爱| 久久精品国产男包| 久久久网中文字幕| 久久这里只有精品久久| 香蕉久久av一区二区三区| 久久福利资源国产精品999| 久久久久国产| 久久九色综合九色99伊人| 91精品免费久久久久久久久| 99热成人精品热久久669| 色欲久久久天天天综合网 | 久久精品国产亚洲AV香蕉| 久久人妻少妇嫩草AV蜜桃| 久久国产一片免费观看| 久久久精品无码专区不卡| 久久激情亚洲精品无码?V| 国产免费久久久久久无码| 91久久成人免费| 欧美亚洲日本久久精品| 无码任你躁久久久久久| 2021久久精品免费观看| 婷婷伊人久久大香线蕉AV|