View Code of Problem 3698

#include <bits/stdc++.h>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		long long h = 1;
		long long  n;
		cin >> n;
		long long l = 1;
		long long x = 1;
		while (n > x) {
			n = n - x;
			h++;
			x = x + h;
		}
		while (n > l) {
			n = n - l;
			l++;
 
		}
		cout << h << " " << l << " " << n << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3698