View Code of Problem 3698

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

Double click to view unformatted code.


Back to problem 3698