It’s a Kind of Magic

시간 제한4초메모리 제한2048 MB

요약
서로 다른 양의 정수로 채운 3x3 정사각형 중 가로, 세로, 대각선의 곱이 모두 같고 그 곱이 n 이하인 것의 개수를 센다.
난이도

어려움10점 중 8점

유형
수학, 정수론
정답자
아직 제출이 없습니다

문제

Everyone knows that a 3×33\times3 magic square must meet two criteria:

  1. All nine numbers must be positive and distinct.
  2. The sums along all rows, columns, and diagonals are equal.

Everyone, except maybe Matt Parker1. He wants to create a magic square of squares, that is, a magic square that also meets a third criterion:

  1. Each number is a square of a positive integer.

His "result" can be seen in the picture in the corner. As you may notice, his square is not that magic... Not only do most of the values appear twice, it also has a diagonal with the wrong sum. To be honest, apart from containing non-square values, there is not much that could make this square worse. Well, at least he tried!

But that is all in the past. After finding the Parker Square, he decided to completely ignore property 33 from now on and to instead give property 22 a new twist. He now considers multiplicative magic squares, which are exactly like normal magic squares except that the products along all rows, columns, and diagonals have to be equal, instead of the sums. Who knows, Matt might even manage to find a proper multiplicative magic square in the future!

With this definition at hand, Matt wrote some terrible Python code -- his words, not ours -- to count the number of multiplicative magic 3×33\times 3 squares where the product of the numbers in a single row, column, or diagonal is at most nn. As you may have guessed by now, his code is way too slow. Therefore, we task you to do the same, just more efficiently. Given an integer nn, count the number of multiplicative magic 3×33\times 3 squares with product at most nn.


1Recreational mathematician, author, comedian, YouTube personality, and science communicator.

입력

The input consists of:

  • One line with an integer tt (1≤t≤1051 \leq t \leq 10^5), the number of test cases.
  • tt lines, each with an integer nn (1≤n≤10181 \leq n \leq 10^{18}), the maximum product.

출력

For each test case, output the number of multiplicative magic squares with product at most nn.

예제1

  1. 예제 1

    입력
    3
    500
    1000
    3000
    
    예상 출력
    8
    16
    56