https://ac.nowcoder.com/acm/contest/11254/E
枚举y <= 1000 的情况发现,对于每一个整数x一定有(x, x^3)满足。
int main(){
    for (int i = 1; i <= 1000; ++i) {
        for (int j = i; j <= 1000; ++j) {
            if((i * i + j * j)%(i * j + 1)==0){
                printf("(x:%d, y:%d)\n", i, j);
            }
        }
    }
    return 0;
}
x^2 + y^2 = k(xy + 1) // k是正整数
 ⇒ y^2 - kxy - k + x^2 = 0 // (1)
 可以将x看成一个固定的值。
 由韦达定理有 y1 + y2 = kx
 对于一对满足条件的(x, y),有一对(x, kx - y)也满足条件。
 所以(y, x)也满足条件,此时y是固定的,有(y, ky - x)条件。
 对于上面打表找出的特例:(x,x^3)带入(1)式,得到 k = x^2。
 所以有:
 (x, x^3)
 (x^3, x^5 - x)
 …
 …
 无线套娃下去
 直到y超出范围。
using namespace std;
typedef __int128 ll;  // unsigned long long 会溢出
vector<ll> da;
template<typename T>void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9){
        write(x/10);
    }
    putchar(x%10+'0');
}
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int main(){
    da.push_back(1);
    // i * i * i <= 1e18
    for (ll i = 2; i <= 1e6; ++i) {
        ll x = i, y = i * i * i, k = i * i;
        while (y <= 1e18){
            da.push_back(y);  // 将y值添加到序列
            ll tmp = k * y - x;
            x = y;
            y = tmp;
        }
    }
    // 排序
    sort(da.begin(), da.end());
    int t;
    cin >> t;
    while (t--){
        ll n;
        read(n);
        int ind = upper_bound(da.begin(), da.end(), n) - da.begin();
        write(ind);
        cout << endl;
    }
    return 0;
}                
                










