#P10584. Counting Perfect Square Products

    ID: 12606 Type: Default 1000ms 256MiB

Counting Perfect Square Products

Counting Perfect Square Products

Given two positive integers n and m, calculate the sum

$$\sum_{i=1}^{n}{\sum_{j=1}^{m}\left|f(i \times j)\right|}$$

where \(|f(x)|\) is defined as follows:

  • If x is a perfect square then \(|f(x)| = 1\).
  • Otherwise, \(|f(x)| = 0\).
  • A perfect square is an integer that can be expressed as the square of another integer. In other words, an integer \(x\) is a perfect square if there exists an integer \(k\) such that \(x=k^2\).

    Your task is to output the computed sum.

    inputFormat

    The input consists of a single line containing two space-separated positive integers, n and m.

    outputFormat

    Output a single integer which is the value of the sum \(\sum_{i=1}^{n}{\sum_{j=1}^{m}\left|f(i \times j)\right|}\).

    sample

    1 1
    1