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

            ArcTan

            dfs
            隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
            數(shù)據(jù)加載中……

            SRM 150 DIV 2 500pt(thinking && 數(shù)論)

            Problem Statement

                

            The digits 3 and 9 share an interesting property. If you take any multiple of 3 and sum its digits, you get another multiple of 3. For example, 118*3 = 354 and 3+5+4 = 12, which is a multiple of 3. Similarly, if you take any multiple of 9 and sum its digits, you get another multiple of 9. For example, 75*9 = 675 and 6+7+5 = 18, which is a multiple of 9. Call any digit for which this property holds interesting, except for 0 and 1, for which the property holds trivially.

            A digit that is interesting in one base is not necessarily interesting in another base. For example, 3 is interesting in base 10 but uninteresting in base 5. Given an int base, your task is to return all the interesting digits for that base in increasing order. To determine whether a particular digit is interesting or not, you need not consider all multiples of the digit. You can be certain that, if the property holds for all multiples of the digit with fewer than four digits, then it also holds for multiples with more digits. For example, in base 10, you would not need to consider any multiples greater than 999.

            Definition

                
            Class: InterestingDigits
            Method: digits
            Parameters: int
            Returns: vector <int>
            Method signature: vector <int> digits(int base)
            (be sure your method is public)
                

            Notes

            - When base is greater than 10, digits may have a numeric value greater than 9. Because integers are displayed in base 10 by default, do not be alarmed when such digits appear on your screen as more than one decimal digit. For example, one of the interesting digits in base 16 is 15.

            Constraints

            - base is between 3 and 30, inclusive.

            Examples

            0)
                
            10
            Returns: { 3,  9 }
            All other candidate digits fail for base=10. For example, 2 and 5 both fail on 100, for which 1+0+0=1. Similarly, 4 and 8 both fail on 216, for which 2+1+6=9, and 6 and 7 both fail for 126, for which 1+2+6=9.
            1)
                
            3
            Returns: { 2 }

            2)
                
            9
            Returns: { 2,  4,  8 }

            3)
                
            26
            Returns: { 5,  25 }

            4)
                
            30
            Returns: { 29 }

            This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.


            題意給定base進制數(shù)里,找出里面所有的特別的數(shù)x,對于x的倍數(shù)kx,它的每一位的和還是x的倍數(shù)。
            比如base=10,則x=3和9。

            這個應(yīng)該是小學(xué)時候就記得的結(jié)論了,專門算3和9的,哈哈。

            結(jié)論:base %x==1是充要條件。
            證明:
                           a=a1*base^0+a2*base^1+a3*base^2,對于任何a都可以這樣分解
                    因為 base % x=1,則base^k %x==1。則上式化簡為
                           a==a1+a2+a3+.. (mod x)
                     反之,也可得base %x==1

            440PT啊,小小猶豫了下哦。直接枚舉了x驗證啊。

            其實就是求base-1的因子,如果base很大地話,是不能這樣去枚舉的。因子分解哦,又是經(jīng)典問題啊。

            #include<stdio.h>
            #include
            <string.h>
            #include
            <vector>
            #include
            <algorithm>
            using namespace std;

            class InterestingDigits{
            public:
                vector 
            <int> digits(int base){
                    
            int a[31];
                    
            int n=0;
                    
            int i=2;
                    
            while (i<base){
                        
            if (base % i==1)
                            a[n
            ++]=i;
                        i
            ++;
                    }
                    vector 
            <int> ans(n);
                    
            for (i=0;i<n;i++)
                        ans[i]
            =a[i];
                    
            return ans;
                }
            };



            posted on 2012-07-15 21:54 wangs 閱讀(253) 評論(0)  編輯 收藏 引用 所屬分類: ACM-數(shù)學(xué)Topcoder

            国产亚洲精久久久久久无码77777| 久久精品国产精品青草app| 久久久久久国产精品无码下载| 性欧美大战久久久久久久| 久久久久亚洲AV成人网人人网站 | 亚洲国产成人久久精品影视| 久久99久久无码毛片一区二区| 青春久久| 久久精品国产一区| 久久人人爽人人爽人人爽| 99久久免费国产特黄| 亚洲国产精品综合久久网络| 97久久精品无码一区二区| 久久伊人精品一区二区三区| 久久久91精品国产一区二区三区 | 人妻无码精品久久亚瑟影视| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 久久久久亚洲AV无码永不| 久久精品无码免费不卡| 国产精品久久久久jk制服| 久久精品国产清自在天天线| 久久精品成人影院| 伊人色综合久久天天人手人婷| 久久有码中文字幕| 久久综合给合久久狠狠狠97色69 | 久久黄色视频| 97精品国产97久久久久久免费| 国产精品9999久久久久| 国产A级毛片久久久精品毛片| 日本久久中文字幕| 国产精品成人99久久久久| 国内精品久久国产大陆| 久久天堂AV综合合色蜜桃网| 中文字幕热久久久久久久| 武侠古典久久婷婷狼人伊人| 亚洲精品成人久久久| 久久久久综合中文字幕| 久久亚洲AV无码西西人体| 天天做夜夜做久久做狠狠| 奇米影视7777久久精品人人爽| 亚洲精品97久久中文字幕无码|