View Code of Problem 3698

#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){     //方法来自前辈
    int t;
    scanf("%d",&t);
    while(t--){
        long long x;
        scanf("%lld",&x);
        long long heap_no=1,row=1,nextheap=1;
        while(x>nextheap){
            x-=nextheap;
            heap_no++;
            nextheap+=heap_no;
        }
        while(x>row){
            x-=row;
            row++;
        }
        printf("%lld %lld %lld\n",heap_no,row,x);
    }
	return 0;
}

Double click to view unformatted code.


Back to problem 3698