题意: 给出两个数字a和b,求a的阶乘转换成b进制后,输出 (1)后缀中有多少个连续的0? (2)数a的b进制表示法中有多少位? 思路:逐个问题解决. 设a!=k.  k暂时不用直接转成b进制. (1)阶乘后缀0问题.先看这个十进制后缀0的例子:http://www.cnblogs.com/xcw0754/p/4604473.html 解法差不多,稍变化. 首先将b分解成若干质数(比如8={2*2*2})保存在一个集合A中(注意自然数的质数分解是唯一的),只要有一个序列A就能构成一个0,因为满b…
How many zeros and how many digits? Input: standard input Output: standard output Given a decimal integer number you will have to find out how many trailing zeros will be there in its factorial in a given number system and also you will have to find…
Given a decimal integer number you will have to find out how many trailing zeros will be there in itsfactorial in a given number system and also you will have to find how many digits will its factorial havein a given number system? You can assume tha…
题目大意:让求n!在base进制下的位数以及末尾0的连续个数. 多少位 log_{10}256=log_{10}210^2+log_{10}510^1+log_{10}6*10^0 可以发现,只和最高位有关,要想进位必须有10^3 ,那么通解: 数值a 在 b 进制下的位数为:floor(log_ba)+1 这里是阶乘化简: log_bn!=log_b1+log_b2+...+log_bn 末尾有多少个0 可以考虑,123456789(25)...(5*600) 即进制的最大质因数,都多少个?…
n!=x*b^y, 当x为正整数时,最大的y就是n!末尾0的个数了, 把n,b分别拆成素因子相乘的形式: 比如, n=5,b=16 n=5,b=2^4, 非常明显,末尾0的个数为0 10进制时,n!=a*10^x b进制时,n!=c*b^y 非常明显,n!的位数就是最大的x+1 这里计算我用了log,精度设置为1e-9 #include<iostream> #include<cstdio> #include<vector> #include<cstring>…
题解:题目要在b进制下输出的是一个数字阶乘后有多少个零,然后输出一共同拥有多少位.首先计算位数,log(n)/log(b) + 1就是n在b进制下有多少位,而log有个公式就是log(M×N) = logM + logN,n! 的位数用公式能够化为( log(1) + log(2) +...+log(n) ) / log(b) + 1.为了精确再加 10^-6.阶乘后的零的数量计算是依据进制数的最大质因数和其数量确定的,比方10 = 2 × 5.所以10进制的最大质因数是5,数量是num = 1…
题目链接:uva 10581 - Partitioning for fun and profit 题目大意:给定m,n,k,将m分解成n份,然后依照每份的个数排定字典序,而且划分时要求ai−1≤ai,然后输出字典序排在k位的划分方法. 解题思路:由于有ai−1≤ai的条件.所以先记忆化搜索处理出组合情况dp[i][j][s]表示第i位为j.而且剩余的未划分数为s的总数为dp[i][j][s],然后就是枚举每一位上的值.推断序列的位置就可以. #include <cstdio> #include…
题意:输入整数n(1<=n<=30000000),有多少对整数(a, b)满足:1<=b<=a<=n,且gcd(a,b)=a XOR b. 分析:因为c是a的约数,所以枚举c,a = k*c,通过a-c求b,并通过a^b=c来验证. #pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio> #include<cstring> #include<…
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes…
问n! 转化成k进制后的位数和尾数的0的个数.[UVA 10061 How many zeros and how many digits?] Given a decimal integer number you will have to find out how many trailing zeros will be there in its factorial in a given number system and also you will have to find how many di…