#P10584. [蓝桥杯 2024 国 A] 数学题

[蓝桥杯 2024 国 A] 数学题

Problem Description

Compute i=1nj=1mf(ij)\sum\limits_{i=1}^n{\sum\limits_{j=1}^m{|f(ij)|}}, where f(x)|f(x)| equals 11 if xx is a perfect square, and 00 otherwise.

Input Format

Input one line containing two positive integers, separated by a space, representing nn and mm 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.

2 3
2
1000000000 1000000000
12735999860

Hint

For 15%15\% of the test cases, n,m105n, m \le 10^5.
For 30%30\% of the test cases, n107n \le 10^7, m109m \le 10^9.
For 50%50\% of the test cases, n,m1011n, m \le 10^{11}.
For 70%70\% of the test cases, n,m1015n, m \le 10^{15}.
For all test cases, 1n,m1.5×10161 \le n, m \le 1.5 \times 10^{16}.

Thanks to

https://www.luogu.com.cn/user/320423
ing the testdata.

Translated by ChatGPT 5