View Code of Problem 3698

#include<stdio.h>
#include<math.h>
#include<string.h>
//#include<algorithm>
#include <bits/stdc++.h>

using namespace std;


int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		long long int n;
		scanf("%lld",&n);
		long long int l=1;
		long long int temp=n;
		long long x=1;
		while(temp>l) {
			temp=temp-l;
			l=l+x+1;
			x++;
		}
		long long int y=1;
		while(temp>y) {
			temp=temp-y;
			y++;
		}
		
		printf("%lld %lld %lld\n",x,y,temp);
	}
}

Double click to view unformatted code.


Back to problem 3698