[蓝桥杯 2018 省 B] 螺旋折线

Luogu
IDLGP8668
Time1000ms
Memory256MB
DifficultyP2
数学2018蓝桥杯省赛
如图所示的螺旋折线经过平面上所有整点恰好一次。 ![](https://cdn.luogu.com.cn/upload/image_hosting/yis43t6j.png) 对于整点 $(X, Y)$,我们定义它到原点的距离 $\text{dis}(X, Y)$ 是从原点到 $(X, Y)$ 的螺旋折线段的长度。 例如 $\text{dis}(0, 1)=3$,$\text{dis}(-2, -1)=9$。 给出整点坐标 $(X, Y)$,你能计算出 $\text{dis}(X, Y)$ 吗? ## Input $X$ 和 $Y$。 ## Output 输出 $\text{dis}(X, Y)$ [samples] ## Note 对于 $40\%$的数据,$-1000\le X,Y\le 1000$。 对于 $70\%$ 的数据,$-10^5\le X,Y \le 10^5$。 对于 $100\%$ 的数据,$-10^9\le X,Y \le 10^9$。
Samples
Input #1
0 1
Output #1
3
API Response (JSON)
{
  "problem": {
    "name": "[蓝桥杯 2018 省 B] 螺旋折线",
    "description": {
      "content": "如图所示的螺旋折线经过平面上所有整点恰好一次。 ![](https://cdn.luogu.com.cn/upload/image_hosting/yis43t6j.png) 对于整点 $(X, Y)$,我们定义它到原点的距离 $\\text{dis}(X, Y)$ 是从原点到 $(X, Y)$ 的螺旋折线段的长度。   例如 $\\text{dis}(0, 1)=3$,$\\text{dis}(",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8668"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "如图所示的螺旋折线经过平面上所有整点恰好一次。\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/yis43t6j.png)\n\n对于整点 $(X, Y)$,我们定义它到原点的距离 $\\text{dis}(X, Y)$ 是从原点到 $(X, Y)$ 的螺旋折线段的长度。  \n\n例如 $\\text{dis}(0, 1)=3$,$\\text{dis}(...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments