# 螺旋折线 如图所示的螺旋折线经过平面上所有整点恰好一次。 对于整点(X, Y),我们定义它到原点的距离dis(X, Y)是从原点到(X, Y)的螺旋折线段的长度。 例如`dis(0, 1)=3, dis(-2, -1)=9` 给出整点坐标(X, Y),你能计算出dis(X, Y)吗? **输入格式** ``` X和Y 对于40%的数据,-1000 <= X, Y <= 1000 对于70%的数据,-100000 <= X, Y <= 100000 对于100%的数据, -1000000000 <= X, Y <= 1000000000 ``` **输出格式** ``` 输出dis(X, Y) ``` **样例输入** ``` 0 1 ``` **样例输出** ``` 3 ``` 以下程序实现了该功能,请你补全空白处内容: ```c #include using namespace std; int main() { int x, y; cin >> x >> y; long long sum = 0; if ((y < x) && (-y <= x)) { sum += x > 1 ? (long long)(4 * (2 + (abs(x) - 1) * (abs(x) - 2))) : 0; sum += (long long)x > 0 ? (4 * x + (x - y)) : (y - x); } else { sum += y > 1 ? (long long)(4 * (2 + (abs(y) - 1) * (abs(y) - 2))) : 0; __________________; } cout << sum << endl; return 0; } ``` ## 答案 ```c sum += (long long)y > 0 ? (2 * y + y + x) : (6 * y - y - x); ``` ## 选项 ### A ```c sum += (long long)y > 0 ? (2 * y + x) : (6 * y - y - x); ``` ### B ```c sum += (long long)y > 0 ? (2 * y + y + x) : (6 * y - x); ``` ### C ```c sum += (long long)y > 0 ? (2 * y + x) : (6 * y - x); ```