View Code of Problem 3698

#include<stdio.h>
#include<math.h>
#include<string.h>
#define inf 0x7fffffff
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		long long int n,d=1,h=1,sum=1;
		scanf("%lld",&n);
		while(n>sum)
		{
			n-=sum;
			d++;
			sum+=d;
		}
		while(n>h)
		{
			n-=h;
			h++;
		}
		printf("%lld %lld %lld\n",d,h,n);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3698