typedef long long ll; #include using namespace std; int main() { ll x,y; std::cin >> x>>y; // r = x^2 + y^2 // xが0からsqrt(r)までを確かめたら答えはでるが、TLE // 二乗足す二乗の和 // 10**3.5個ある // 0,1,4,9,16,,,10**7 // 前計算でありえる値を計算! // 既に二乗なら+4; vector sekilist; unordered_map cou; ll sq = sqrt(y); for (int i = 1; i <= sq; i++) { sekilist.push_back(i*i); for (auto e : sekilist) { if( i*i != e ){ cou[i*i+e]+=8; }else{ cou[i*i+e]+=4; } } } ll result = -1; vector can = { 0, 1, 4, 9, 16, 17, 25, 33, 36, 41, 49, 57, 64, 65, 68, 73, 81, 89, 97, 100, 105, 113, 121, 129, 132, 137, 144, 145, 153, 161, 164, 169, 177, 185, 193, 196, 201, 209, 217, 225, 228, 233, 241, 249 }; for (int i = x; i <= y; i++) { ll now = 0; ll m=i%256; bool able = false; for (auto e : can) { if(m == e){ able = true; break; } } if(able){ std::cout << i<< std::endl; ll ssq = (int)sqrt(i); if(i == ssq*ssq){ now+=4; } } now += cou[i]; result = max(result,now); } std::cout << result << std::endl; }