Skip to content

Instantly share code, notes, and snippets.

@tuhdo
Created June 7, 2017 13:04
Show Gist options
  • Save tuhdo/b1ed7a4918866d9d60341755aab35bb8 to your computer and use it in GitHub Desktop.
Save tuhdo/b1ed7a4918866d9d60341755aab35bb8 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef char i8;
typedef short i16;
typedef int i32;
typedef long long i64;
typedef pair<int, int> ii;
#define repc(e,c) for(__typeof((c).begin()) e=(c).begin(), _##e=(c).end(); e !=_##e; ++e)
#define rrepc(e,c) for(__typeof((c).rbegin()) e=(c).rbegin(), _##e=(c).rend(); e!=_##e; ++e)
#define rep(__i, __begin, __end) for (int __i = __begin; __i < __end; __i++)
#define rrep(__i, __end, __begin) for (int __i = __end; __i >= __begin; __i--)
#define repi(n) rep(i, 0, n)
#define repj(n) rep(j, 0, n)
#define repk(n) rep(k, 0, n)
// syntactic sugar
#define fastio do {std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);} while(0)
/*******************/
/* END DECLARATION */
/*******************/
int main()
{
fastio;
// Variables
// Input
int n;
cin >> n;
u64 v, k, x = 1, y;
repi (n) {
x = 1, y = 0;
cin >> v;
y = ceil(sqrt(v));
k = y * y;
if (y >= k - v + 1) {
x += k - v;
} else {
x += y - 1;
y -= k - y + 1 - v;
}
if (k % 2 == 0) swap(x, y);
cout << "Case " << i + 1<< ": "<< x << ' ' << y << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment