---
title: "F(X)"
author: "vcdemon"
date: "2014-06-13T11:27:18Z"
tags: []
categories: ["编程语言"]
slug: "f-x"
draft: false
lastmod: "2014-06-14T20:00:02Z"
id: 2079107
url: "https://tbk.iteye.com/blog/2079107"
---

## F(X)

## 题目详情:

我们定义 F（x）是满足 x  mod（a\*b） == 0这样的a，b的组数。现在给你一个n，你需要求出 F（n）

输入格式：

多组数据，每组第一行有一个整数n, 0 &lt; n &lt;= 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.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class TestFive {
    public static Integer Test(long n) {
        if (n == 1) {
            return 1;
        }
        return PrintPrimeFactors(n) * 3;
    }

    public static Integer PrintPrimeFactors(long n) {
        Integer count0 = 0;
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        for (int i = 2; i <= n; i++) {
            while (n % i == 0) {
                if (!arrayList.contains(i)) {
                    arrayList.add(i);
                }
                if (map.containsKey(i)) {
                    Integer count = map.get(i);
                    count++;
                    map.remove(i);
                    map.put(i, count);
                } else {
                    map.put(i, 1);
                }
                n = n / i;
            }
        }

        for (int i = 0; i < map.size(); i++) {
            count0 = CombineArray(map.get(arrayList.get(i)), count0);
        }
        return count0;
    }

    public static Integer CombineArray(Integer m, Integer n) {
        return (m + n + m * n);
    }

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while (cin.hasNext()) {
            long n = cin.nextLong();
            System.out.println(Test(n));
        }
        cin.close();
    }
}
```