一道基础的ACM数学编程题When we were young,everyone was taught that:"If the sum of a number's each bit could be exactly divided by 3,then itself would be exactly divided by 3",so for a k-base number,if that the sum of its each bit could be e

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 02:38:22
一道基础的ACM数学编程题Whenwewereyoung,everyonewastaughtthat:"Ifthesumofanumber''seachbitcouldbeexactlydividedb

一道基础的ACM数学编程题When we were young,everyone was taught that:"If the sum of a number's each bit could be exactly divided by 3,then itself would be exactly divided by 3",so for a k-base number,if that the sum of its each bit could be e
一道基础的ACM数学编程题
When we were young,everyone was taught that:"If the sum of a number's each bit could be exactly divided by 3,then itself would be exactly divided by 3",so for a k-base number,if that the sum of its each bit could be exactly divided by n can infer that the number itself would be exactly divided by n,then we called n is a "Skillful Dividing" number on k-base.To find all of the "Skillful Dividing" numbers on k-base is not easy ,but your task is just to find all of "Skillful Dividing" numbers,SD number for short.
输入要求
Input consists of multiple test case .Each case will include a k,input will end with EOF.
输出要求
For each test case,print the amount of SD numbers on k-base
假如输入
10
4
应当输出
3
2
提示
1,3,9 are SD numbers on 10-base.
每一位相加能被3整除的数这个数可以被3整除,对于一个有k位的数,每一位相加能被n整除,那么这个数就能被n整除,n叫做Skillful dividing number on k-base(k位数被有效划分的数,缩写SD),n是短整型数,要求输入多测试数据,每个数据是k,输入EOF为止,输出SD数的个数
思路正确者加分

一道基础的ACM数学编程题When we were young,everyone was taught that:"If the sum of a number's each bit could be exactly divided by 3,then itself would be exactly divided by 3",so for a k-base number,if that the sum of its each bit could be e
纠结下,k-base 这是指k进制,不是指k位的数.
这个题的意思是,找出n的个数,n的意思是,能被一个多位数整除,同时该每个数相加后也能被整除.
下面说下为什么这个多位数(m位)有这种性质.
比如这个多位数是data. 在k进制下有,
data=(ai)*k^(m-i-1) (i=0...m-1 ; ai表示data的每一位)
如果存在一个p,使得 k mod p = 1 则 对于所有的 k^(i) mod p =1
那个 data mod p = ai (i=0,m-1) .
也就是 p就是我们所要找的, 而寻找的方法 就是 for(i=1;i 10^0 mod 3=1 .. 10^2 mod 3= 1 (同余的性质 )
所以 123 mod 3 = (1+ 2 +3 ) mod 3
如果右边相加能被3整除,即左边为0 ,那右边也为0 .

一道基础的ACM数学编程题When we were young,everyone was taught that:If the sum of a number's each bit could be exactly divided by 3,then itself would be exactly divided by 3,so for a k-base number,if that the sum of its each bit could be e 阶乘所得结果的位数怎么算?这是一道acm编程题. 一道数学编程题N 编程ACM的一道题There are several test cases.For each test case,standard input contains a line with n 一道数学基础题,why? 一道acm的排序题Snow_storm有n(0 一道基础的数学证明a 一道编程题,编程计算100~100000之间,共有多少个整数,满足它的各位数学之和可被3整除. acm的一道c语言问题 关于数学的一道计算基础题左边怎样变成右边? 一道初三数学圆的基础题AB=CD 求证PB=PD 高等数学一道基础的数学证明题设a>b>0,证明:(a-b)/a 高一数学反涵数的一道基础题 arc tan(tan 5派/4)..怎么算? 一道高一数学A卷(基础题) &&&&&&&&&&&【高一数学 最值 基础题一道】&&&&&&&&&&&k 数学编程高手请进一道求公式的题目求这个题目的公式, 求助一道英语基础题!_____ we were when we heard the news that our country won 51 gold medals at the Beijing Olympics!A.What fun B.What a fun C.How happy D.How happily为什么? 一道ACM的编程题,帮忙看下哪儿错了⊙﹏⊙b汗.新人,如果可以的话,顺便说个简单点的代码吧.Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形:1 1 1