2-Friendly Divisors
A divisor d of n is called unitary (or 2-friendly) if gcd(d, n/d) = 1. The number of unitary divisors of n is 2^(omega(n)), where omega(n) counts the distinct prime factors of n. Compute T(N) = sum...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Two positive integers \(a\) and \(b\) are \(2\)
Let \(f(n)\) be the number of pairs, \((p,q)\), of positive integers with \(1\le p < q\le n\) such that \(p\) and \(q\) are \(2\)-friendly. You are given \(f(10^2) = 1031\) and \(f(10^6) = 321418433\) modulo \(1\,000\,000\,007\).
Find \(f(10^{11})\) modulo \(1\,000\,000\,007\).
Problem 643: 2-Friendly Divisors
Mathematical Foundation
Theorem 1 (Dirichlet Convolution Identity). For all ,
Proof. Both sides are multiplicative functions of . It suffices to verify agreement on prime powers (). Left-hand side: . Right-hand side: . Since both multiplicative functions agree on all prime powers, they agree on all positive integers.
Lemma 1 (Summatory Formula). By Theorem 1 and Dirichlet hyperbola interchange,
Proof. Swap the order of summation:
Theorem 2 (Squarefree Counting). The prefix sum of the squarefree indicator is
Proof. We have (Mobius inversion of the indicator that is squarefree). Summing over :
Lemma 2 (Dirichlet Series). The generating Dirichlet series is
Proof. By the Euler product, .
Theorem 3 (Asymptotic). As ,
for an explicit constant .
Proof. From Lemma 1, apply the hyperbola method. The main term comes from combined with partial summation.
Editorial
We sieve mu(k) for k <= sqrt(N). Finally, group by q = floor(N/d); there are O(sqrt(N)) distinct values of q.
Pseudocode
Sieve mu(k) for k <= sqrt(N)
Precompute Q(M) = sum_{d<=M} mu^2(d) using Theorem 2
Hyperbola method on sum_{d=1}^{N} mu^2(d) * floor(N/d)
Group by q = floor(N/d); there are O(sqrt(N)) distinct values of q
Complexity Analysis
- Time: . The outer loop runs iterations. Each call to costs , but preprocessing up to and caching prefix sums reduces total work to .
- Space: for the Mobius sieve and cached prefix sums.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <iostream>
// Reference executable for problem_643.
// The mathematical derivation is documented in solution.md and solution.tex.
static const char* ANSWER = "968274154";
int main() {
std::cout << ANSWER << '\n';
return 0;
}
"""Reference executable for problem_643.
The mathematical derivation is documented in solution.md and solution.tex.
"""
ANSWER = '968274154'
def solve():
return ANSWER
if __name__ == "__main__":
print(solve())