View Code of Problem 3698

#include<iostream>
using namespace std;

int main() {
	int T;
	cin >> T;
	while (T--) {
		long long n, a = 1, b = 1, count = 0;
		cin >> n;
		while (1) {
			n -= a;
			count++;
			if (n <= 0)break;
			a += (++b);
		}
		n += a;
		long long row = 1;
		while (n > row) {
			n -= row;
			row++;
		}
		printf("%lld %lld %lld\n", count, row, n);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3698