Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1492
Here, let's talk about the theorem of number of numbers:
For positive integer x, decompose the mass due to x = Pow (P1, a) * pow* (P2, b) * POW (P3, c) * ...
The approximate number of digits is: num (x) = (a+1) * (b+1) * (c+1) * ...
Derivation:
The approximate definition of P1^A1 is as follows: P1^0, P1^1, P1^2......P1^A1, Total (a1+1); the same as P2^A2 's approximate (a2+1). There are (Pk^ak) an approximate ak+1. Therefore, according to the multiplication principle: N of the number of approximate is (a1+1) (a2+1) (a3+1) ... (ak+1).
So this problem is a direct substitute for this formula.
Test instructions
A number of 64bit is given, and the number of its approximate numbers is obtained;
Code:
1#include <iostream>2#include <stdio.h>3 #definell Long Long4 using namespacestd;5 6 intMainvoid){7 ll N;8 while(SCANF ("%lld", &n) &&N) {9 inta[4]={1,1,1,1};Ten intb[4]={2,3,5,7}; One for(intI=0; i<4; i++){ A while(n%b[i]==0){ -a[i]++; -N/=B[i]; the } - } -printf"%d\n", a[0]*a[1]*a[2]*a[3]); - } + return 0; -}
hdu1492 (approximate number theorem)