P10584 [Lanqiao Cup 2024 National A] Math Problem
Description
Compute $\sum\limits_{i=1}^n{\sum\limits_{j=1}^m{|f(ij)|}}$, where $|f(x)|$ equals $1$ if $x$ is a perfect square, and $0$ otherwise.
Input Format
Input one line containing two positive integers, separated by a space, representing $n$ and $m$ in the problem statement.
Output Format
Output one line containing one positive integer, representing the answer.
Hint: The testdata guarantees that the answer will not exceed the range representable by `unsigned long long`.
Explanation/Hint
For $15\%$ of the test cases, $n, m \le 10^5$.
For $30\%$ of the test cases, $n \le 10^7$, $m \le 10^9$.
For $50\%$ of the test cases, $n, m \le 10^{11}$.
For $70\%$ of the test cases, $n, m \le 10^{15}$.
For all test cases, $1 \le n, m \le 1.5 \times 10^{16}$.
Thanks to @[ACaCaca_](https://www.luogu.com.cn/user/320423) for providing the testdata.
Translated by ChatGPT 5