In the 17th century, with thunderous noise, dense smoke and blazing fire, battles on the sea were just the same as those in the modern times. But at that time, the cannon ,were extremely simple. It was just like an iron cylinder, with its rearward end sealed and forward end open. There was a small hole at the rearward end of it, which was used to install the fuse. The cannons on the warships were put on small vehicles which had four wheels and the shells were iron spheres with gunpowder in them.
At that time, it was said that there was an intelligent captain, who was also a mathematician amateur. He liked to connect everything him met to mathematics. Before every battle, he often ordered the soldiers to put the shells on the deck and make those shells to form shell pyramids.
Now let's suppose that a shell pyramid has four layers, and there will be a sequence of ordinal numbers in every layer. They are as the following figure:
In the figure, they are the first layer, the second layer, the third layer and the fourth layer respectively from the left to the right.
In the first layer, there is just 1 shell, and its ordinal number is 1. In the second layer, there are 3 shells, and their ordinal numbers are 1, 2, and 3. In the third layer, there are 6 shells, and their ordinal numbers are 1, 2, 3, 4, 5, and 6. In the fourth layer, there are 10 shells, and their ordinal numbers are shown in the figure above.
There are also serial numbers for the whole shell pyramid. For example, the serial number for the third shell in the second layer is 4, the serial number for the fifth shell in the third layer is 9, and the serial number for the ninth shell in the fourth layer is 19.
There is also a interrelated problem: If given one serial number s, then we can work out the s th shell is in what layer, what row and what column. Assume that the layer number is i, the row number is j and the column number is k, therefore, if s=19, then i=4, j=4 and k=3.
Now let us continue to tell about the story about the captain.
A battle was going to begin. The captain allotted the same amount of shells to every cannon. The shells were piled on the deck which formed the same shell pyramids by the cannon. While the enemy warships were near, the captain ordered to fire simultaneously. Thunderous sound then was heard. The captain listened carefully, then he knew that how many shells were used and how many were left.
At the end of the battle, the captain won. During the break, he asked his subordinate a question: For a shell pyramid, if given the serial number s, how do you calculate the layer number i, the row number j and column number k?
First input a number n,repersent n cases.For each case there a shell pyramid which is big enough, a integer is given, and this integer is the serial number s（s<2^63）. There are several test cases. Input is terminated by the end of file.
For each case, output the corresponding layer number i, row number j and column number k.
4 4 3
769099 111570 11179
- 博客 在中国程序员是青春饭吗？
- 博客 程序员请照顾好自己，周末病魔差点一套带走我。
- 博客 C++(数据结构与算法)78:---分而治之
- 博客 springboot+jwt实现token登陆权限认证
- 博客 技术大佬：我去，你写的 switch 语句也太老土了吧
- 博客 win10暴力查看wifi密码
- 博客 女程序员，为什么比男程序员少？？？
- 博客 副业收入是我做程序媛的3倍，工作外的B面人生是怎样的？
- 博客 MySQL数据库面试题（2020最新版）
- 博客 如果你是老板，你会不会踢了这样的员工？
- 博客 我入职阿里后，才知道原来简历这么写
- 博客 程序员写出这样的代码，能不挨骂吗？
- 博客 带了6个月的徒弟当了面试官，而身为高级工程师的我天天修Bug......
- 博客 优雅的替换if-else语句
- 博客 !大部分程序员只会写3年代码
- 博客 离职半年了，老东家又发 offer，回不回？
- 博客 2020阿里全球数学大赛：3万名高手、4道题、2天2夜未交卷
- 博客 为什么你不想学习？只想玩？人是如何一步一步废掉的
- 博客 男生更看重女生的身材脸蛋，还是思想？
- 博客 为什么程序员做外包会被瞧不起？
- 博客 当HR压你价，说你只值7K，你该怎么回答？
- 博客 面试：第十六章：Java中级开发
- 博客 早上躺尸，晚上干活：硅谷科技公司这么流行迟到？
- 博客 面试阿里p7，被按在地上摩擦，鬼知道我经历了什么？
- 博客 Python爬虫，高清美图我全都要（彼岸桌面壁纸）
- 博客 无代码时代来临，程序员如何保住饭碗？
- 博客 面试了一个 31 岁程序员，让我有所触动，30岁以上的程序员该何去何从？
- 博客 大三实习生，字节跳动面经分享，已拿Offer
- 博客 程序员垃圾简历长什么样？
- 博客 Java岗开发3年，公司临时抽查算法，离职后这几题我记一辈子