我们定义 F(x)是满足 x mod(a*b) == 0这样的a,b的组数。现在给你一个n,你需要求出 F(n) 输入格式: 多组数据,每组第一行有一个整数n, 0 < n <= 10^11。 输出格式: 每组输出一行,满足条件的(a,b)对数
挑战规则:
挑战规则:
输入样例 1 2 3 4 输出样例: 1 3 3 6 解释 第一组: (1,1) 第二组: (1,1) (1,2) (2, 1) 第三组: (1,1) (1,3) (3,1) 第四组: (1,1) (1,2) (1, 4) (2, 1) (2,2) (4,1)
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.util.Date;
import java.util.Scanner;
public class demo {
public static void main(String[] args) throws ParseException, IOException {
int result = 0;
//获取输入行的字符串
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int res = 0;
int c = Integer.parseInt(str);
int d = numberT(c);
res = 2*d-1;
if(boolT(c)&&c!=1){
res=res+1;
}
result=res;
System.out.println(result);
}
//求约数
public static int numberT(int num1){
int numT = 0;
for(int i=1;i<=num1;i++){
if(num1%i==0){
numT++;
}
}
return numT;
}
//判断是否可以开根
public static boolean boolT(int num1){
float numS = (float) Math.sqrt((double)num1);
if(numS==(int)numS){
return true;
}else{
return false;
}
}
}