数字螺旋

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

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

image

你的任务是找出第x行第y列的数字。

输入

第一行输入包含一个整数t:测试次数。

在此之后,t行,每行包含整数x和y。

输出

对于每个测试,打印第x行第y列的数字。

约束

  • 1t1051≤t≤10^5
  • 1y,x1091≤y,x≤10^9
3
2 3
1 1
4 2
8
1
15

一起比赛欢乐多

Not Attended
Status
Done
Rule
Ledo
Problem
22
Start at
2024-7-29 19:00
End at
2024-7-29 21:00
Duration
2 hour(s)
Host
Partic.
0