Question: Write to java Arrange sweet desserts ( SweetStack ) At the party welcoming new friends to the Department of Computer Science A set of beautiful,

Write to java
Arrange sweet desserts (SweetStack)
At the party welcoming new friends to the Department of Computer Science A set of beautiful, round sweet treats was ordered at the S set. One set had all Ki sweet treats (1<= i <= S). The students were tasked with arranging these sweet treats into layers. top floor It's called layer 1 and the bottom layer is called layer Ni. Each layer must have the same number of snacks as the number for that layer. For example, If there are 6 desserts in total, the desserts will be arranged exactly 3 levels high, as shown in Figure 1.
Figure 1: Arrangement of dessert layers in Set 1, which has a total of K1=6 pieces, according to the characteristics specified in the problem, resulting in a total of N1=3 layers exactly.
Have students write a program to find out. From the total number of desserts provided in each set How many layers can the dessert be arranged? And how many unused snacks will be left?
input data
The input data has S +1 line as follows.
Line one Consists of one integer. Specify the number of dessert sets. S is set to 1<= S <=20.
Lines 2 through S +1 each contain one integer. Specify the number of sweets within the set (1<= Ki <=999)
note
Specify that every input always has the correct format, bounds, and set of possible values. Students do not need to validate their input.
Export data
The exported data has S lines.
Each line shows the result of arranging desserts in set i into two integers. The first number indicates the number of the bottom layer (Ni) and the last number indicates the number of snacks left from sorting. Separate each number with one space.
Example 1
input data
1
6
Export data
30
Example 2
input data
3
5
6
9
Export data
22
30
33

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!