#include <iostream>
int main() {
int n, k;
std::cout << "Nhap so tang cua thap n: ";
std::cin >> n;
std::cout << "Nhap so luong khoi lap phuong k: ";
std::cin >> k;
int soLuongKhoi = (n * (n + 1) * (2 * n + 1)) / 6;
int soTangToiDa = 0;
while (k >= soLuongKhoi) {
soTangToiDa++;
k -= soLuongKhoi;
n++;
soLuongKhoi = (n * (n + 1) * (2 * n + 1)) / 6;
}
std::cout << "a) So luong khoi lap phuong Be An da dung de xep duoc thap co chieu cao " << n << " tang: " << soTangToiDa << std::endl;
std::cout << "b) So tang thap nhieu nhat co the xep duoc tuong ung voi so luong khoi lap phuong " << k << " ma Be An dang co: " << n - 1 << std::endl;
return 0;
}