CSES Problemset/Introductory Problems
Number Spiral
#1071Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopA number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral:
Input
The first input line contains an integer : the number of tests.
After this, there are lines, each containing integers and .
Output
For each test, print the number in row and column .
Constraints
Sample Test Cases (1)
Example 1ID: sample-1
Input
3 2 3 1 1 4 2
Expected Output
8 1 15
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
3 2 3 1 1 4 2
Expected Output
8 1 15