Given an integer nn, find the number of positive integers (x, y) (x, y) satisfies 1x + 1y = 1n! 1x + 1y = 1n !.
Input format
an integer nn.
Output formats
an integer representing the number satisfying the condition number.
The answer to 7109 + 109 + 7 mod.
Data range
1≤n≤1061≤n≤106
Input Sample:
2
Sample output:
3
Sample explained
There are three pairs of (x, y) (x, y) satisfies the condition, respectively (3,6), (4,4), (6,3), (3,6), (4,4 ), (6,3).
Ideas: After a series of mathematical deformation is obtained finally found 2 * n! Number divisor
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6 + 10, mod = 1e9 + 7;
typedef long long LL;
int primes[N], cnt;
bool st[N];
void init(int n){
for (int i = 2; i <= n; i ++){
if (!st[i]) primes[cnt ++] = i;
for (int j = 0; j * primes[i] <= n ; j ++ ){
st[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
}
int main(){
int n;
cin >> n;
init(n);
int res = 1;
for (int i = 0; i < cnt; i ++){
int p = primes[i];
int s = 0;
for (int j = n; j ; j /= p) s += j/p;
res = (LL)res * (2 * s + 1) % mod;
}
cout << res << endl;
return 0;
}