#include #include //#include #include #include using namespace std; int paint(vector >& height, int m, int n){ int counter = 0; vector > p(m, vector(m, -1)); for (int i = 0; i < m; i++){ for (int j = 0; j < m; j++){ if ((p[i][j] > 0) || (height[i][j] == 0)){ continue; }else{ bool i0flag(false), j0flag(false); if (i == 0) i0flag = true; if (j == 0) j0flag = true; //queue > q; vector > q; //q.push(pair(i, j)); q.push_back(pair(i, j)); while(q.size() > 0){ //pair now = q.front(); pair now = q.back(); //q.pop(); q.pop_back(); //if ((p[now.first][now.second] > 0) || (height[now.first][now.second] != height[i][j])) if (height[now.first][now.second] != height[i][j]) continue; else{ p[now.first][now.second] = 1; if (now.first == 0) i0flag = true; if (now.second == 0) j0flag = true; //if (now.first > 0){ if ((now.first > 0) && (p[now.first-1][now.second] < 0)){ //q.push(pair(now.first-1, now.second)); q.push_back(pair(now.first-1, now.second)); } //if (now.second > 0){ if ((now.second > 0) && (p[now.first][now.second-1] < 0)){ //q.push(pair(now.first, now.second-1)); q.push_back(pair(now.first, now.second-1)); } //if (now.first < (m - 1)){ if ((now.first < (m-1)) && (p[now.first+1][now.second] < 0)){ //q.push(pair(now.first+1, now.second)); q.push_back(pair(now.first+1, now.second)); } //if (now.second < (m - 1)){ if ((now.second < (m-1)) && (p[now.first][now.second+1] < 0)){ //q.push(pair(now.first, now.second+1)); q.push_back(pair(now.first, now.second+1)); } } } if (i0flag && j0flag) counter++; else if (i0flag || j0flag) counter += 2; else counter += 4; } } } return counter; } vector > height_v(1000, vector(1000, 0)); int main(){ int n; while(cin >> n){ double r = sqrt((double)n); int m = (int)ceil(r); for (int i = 0; i < m; i++){ for (int j = 0; j < m; j++){ double z_2 = n-i*i-j*j; if (z_2 <= 0) height_v[i][j] = 0; else height_v[i][j] = (int)ceil(sqrt(z_2)); } } cout << paint(height_v, m, n) * 6 << endl; } return 0; }