#3250. 数字螺旋Number Spiral

    ID: 3250 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>其他数学CSES Introductory Problems

数字螺旋Number Spiral

题目描述

数字螺旋是一个无限大的网格,其左上角方格中的数字为 11。以下是螺旋的前五层:

image

你的任务是找出第 yy 行第 xx 列的数字。

输入格式

第一行包含一个整数 tt:测试数据组数。

接下来 tt 行,每行包含两个整数 yy 和 xx。

输出格式

对于每组测试数据,输出第 yy 行第 xx 列的数字。

3
2 3
1 1
4 2
8
1
15

数据范围与提示

1≤t≤1051 \le t \le 10^5 1≤y,x≤1091 \le y,x \le 10^9

Statistics

Related

In following homework:

国庆5上午