Skip to content

Commit

Permalink
Number Spiral
Browse files Browse the repository at this point in the history
  • Loading branch information
tynnp authored Dec 25, 2024
1 parent 4db27dd commit 4000bf8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
30 changes: 30 additions & 0 deletions CSES/Introductory Problems/1071.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

long long t, x, y;
cin >> t;

while (t--) {
cin >> x >> y;

if (x >= y) {
if (x & 1)
cout << x * (x - 2) + y + 1;
else
cout << x*x - y + 1;
} else {
if (y & 1)
cout << y*y - x + 1;
else
cout << y * (y - 2) + x + 1;
}

cout << '\n';
}

return 0;
}
36 changes: 0 additions & 36 deletions CSES/Introductory Problems/Number Spiral.cpp

This file was deleted.

0 comments on commit 4000bf8

Please sign in to comment.