1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| import java.util.Scanner;
public class 阶乘约数 {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); System.out.println(slove(num)); }
public static long slove(int num){ int data[] = new int[num+1]; for(int i = 1 ; i <=num ; ++i){ slove2(i,data); }
long ans =1; for(int i =1 ; i <=num ; ++i){ if(data[i]==0) continue; ans*=(data[i]+1); } return ans; } public static void slove2(int num,int data[]){
for(int i= 2 ; i <=Math.sqrt(num) ; ++i){
if(num%i==0){ while(num%i==0){ num/=i; ++data[i]; } } } if(num>1){ ++data[num]; } }
}
|