diff --git a/CSES/Introductory Problems/1071.cpp b/CSES/Introductory Problems/1071.cpp new file mode 100644 index 00000000..f1d9f9f4 --- /dev/null +++ b/CSES/Introductory Problems/1071.cpp @@ -0,0 +1,30 @@ +#include +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; +} \ No newline at end of file diff --git a/CSES/Introductory Problems/Number Spiral.cpp b/CSES/Introductory Problems/Number Spiral.cpp deleted file mode 100644 index d251a858..00000000 --- a/CSES/Introductory Problems/Number Spiral.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -using namespace std; - -#define endl '\n' -#define int long long -#define inp freopen("file.inp", "r", stdin) -#define out freopen("file.out", "w", stdout) -#define TIME 1.0*clock()/CLOCKS_PER_SEC -#define fastIO ios_base::sync_with_stdio(0); cin.tie(0) - -const int MAXN = 1e6 + 5; -const int MOD = 1e9 + 7; - -int t, x, y; - -void solve() { - cin >> x >> y; - - if (x >= y) { - if (x & 1) cout << x*x - 2*x + y + 1; - else cout << x*x - y + 1; - cout << endl; - return; - } - - if (y & 1) cout << y*y - x + 1; - else cout << y*y - 2*y + x + 1; - cout << endl; -} - -signed main() { - fastIO; - cin >> t; - while (t--) solve(); - return 0; -} \ No newline at end of file