This page is still under construction.

Parts of this page are still being built. What you see may change.

Triples

Time limit5sMemory limit256 MB

Summary
Count triples x<=y<=z<=m with x^j+y^j=z^j for each exponent j from 2 to n and print the total.
Level

Easy2 of 10

Topics
Brute force, Math
Solved
No attempts yet

Problem

Two positive integers mm and nn are given, with 5≤m≤1005 \le m \le 100 and 2≤n≤1002 \le n \le 100. For each exponent jj, define the set of triples

Tm,j={(x,y,z)∈N3∣x≤y≤z≤m, xj+yj=zj},j=2,3,…,nT_{m,j} = \{(x, y, z) \in \mathbb{N}^3 \mid x \le y \le z \le m,\ x^j + y^j = z^j\}, \quad j = 2, 3, \dots, n

where N\mathbb{N} is the set of nonnegative integers, that is N={0,1,2,… }\mathbb{N} = \{0, 1, 2, \dots\}.

Compute the sum Sm,nS_{m,n}:

Sm,n=∑j=2ncard⁡(Tm,j)S_{m,n} = \sum_{j=2}^{n} \operatorname{card}(T_{m,j})

Here card⁡(Tm,j)\operatorname{card}(T_{m,j}) is the number of elements of the set Tm,jT_{m,j}.

Input

The first line contains mm. The second line contains nn.

Output

Print the value of Sm,nS_{m,n}.

Examples2

  1. Example 1

    Input
    85
    95
    
    Expected output
    8128
    
  2. Example 2

    Input
    5
    2
    
    Expected output
    7