Input Format The first line of input contains a positive integer T denoting the number of test cases that follow. Each test case is described in a single line containing a single integer N denoting the number of ice cream bars you have. Output Format For each test case, output a single line containing the number of days you can eat for before running out of ice cream bars and not being able to fully eat the next day. Constraints 1 s T ≤ 100 Main Test Set 1 ≤ N≤ 105 Bonus Test Set 1 1 ≤ ≤ 10¹5 Careful! If you are a Java or C/C++ programmer, be aware that the int variable type may be too small to contain N! Java programmers can use variable types long or float instead, and likewise long long or float for C/C++. Bonus Test Set 2 1sNs1010000 Careful! Values of N in this test set are extremely large! They exceed the maximum values of 64 bit integers and floats. This one can be quite tricky to get right, so we recommend trying other problems first if you're stuck. Sample Test Cases Sample Input 0 1 2 3 6 11 69 Sample Output 0 1 1 2 3 4 11 51 156 1337 12345 Sample Explanations For test case 1, For test case 1, you have no ice cream bars. You can't eat any at all. Thus, you can only eat for 0 days. For test case 2, you have 1 ice cream bar. You eat your only bar on day 1, and then won't have enough for day 2. Thus, you can only eat for 1 days. For test case 3, you have 2 ice cream bars. You eat your first bar on day 1, and then won't have enough for day 2 because you need 2 but only have 1 more. Thus, you can only eat for 1 day. For test case 4, you have 3 ice cream bars. You eat your first bar on day 1, and then your last 2 bars on day 2. You won't have enough for day 3. Thus, you can eat for 2 days. For test case 5, you have 6 ice cream bars. You eat 1 bar on day 1, 2 bars on day 2, and 3 bars. on day 3. You won't have enough for day 4. Thus, you can eat for 3 days. For test case 6, you have 11 ice cream bars. You eat 1 bar on day 1, 2 bars on day 2, 3 bars on day 3, and 4 bars on day 4. Since you only have 1 left, you won't have enough for day 5. Thus, you can eat for 4 days.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Solve this problem in Java or Python (not both). Feel free to ignore "Bonus Test Set 1" or "Bonus Test Set 2"

Introduction
Summer's finally here, and it's the perfect time to eat ice cream! For the past few months,
you've been saving a stash of delicious ice cream bars for this very moment! You decide to
come up with a plan to savor these tasty treats: on day 1, you eat 1 bar; on day 2, you eat 2
bars; on day 3, you eat 3 bars, and so on.
Oh, Haagen Dazs, if you wanna give us money, we're looking for sponsors ;)
Problem Statement
Given N bars of ice cream, find the number of days you can eat following your plan until you
run out and won't be able to eat the full amount planned for the next day.
On day 1, you eat 1 bar. On day 2, you eat 2 bars. On day 3, you eat 3 bars, and so on. In other
words, on day d, you eat d bars.
Transcribed Image Text:Introduction Summer's finally here, and it's the perfect time to eat ice cream! For the past few months, you've been saving a stash of delicious ice cream bars for this very moment! You decide to come up with a plan to savor these tasty treats: on day 1, you eat 1 bar; on day 2, you eat 2 bars; on day 3, you eat 3 bars, and so on. Oh, Haagen Dazs, if you wanna give us money, we're looking for sponsors ;) Problem Statement Given N bars of ice cream, find the number of days you can eat following your plan until you run out and won't be able to eat the full amount planned for the next day. On day 1, you eat 1 bar. On day 2, you eat 2 bars. On day 3, you eat 3 bars, and so on. In other words, on day d, you eat d bars.
Input Format
The first line of input contains a positive integer T denoting the number of test cases that
follow. Each test case is described in a single line containing a single integer N denoting the
number of ice cream bars you have.
Output Format
For each test case, output a single line containing the number of days you can eat for before
running out of ice cream bars and not being able to fully eat the next day.
Constraints
1 ≤ T ≤ 100
Main Test Set
1 ≤ N≤ 105
Bonus Test Set 1
1 ≤ N≤ 1015
Careful! If you are a Java or C/C++ programmer, be aware that the int variable type may be too
small to contain N! Java programmers can use variable types long or float instead, and likewise
long long or float for C/C++.
Bonus Test Set 2
1 ≤N≤ 1010000
Careful! Values of N in this test set are extremely large! They exceed the maximum values of 64
bit integers and floats. This one can be quite tricky to get right, so we recommend trying other
problems first if you're stuck.
Sample Test Cases
Sample Input
9
0
1
2
3
6
11
69
Sample Output
OHHN34
0
1
1
2
11
51
156
1337
12345
Sample Explanations
For test case 1, For test case 1, you have no ice cream bars. You can't eat any at all. Thus, you
can only eat for 0 days.
For test case 2, you have 1 ice cream bar. You eat your only bar on day 1, and then won't have
enough for day 2. Thus, you can only eat for 1 days.
For test case 3, you have 2 ice cream bars. You eat your first bar on day 1, and then won't have
enough for day 2 because you need 2 but only have 1 more. Thus, you can only eat for 1 day.
For test case 4, you have 3 ice cream bars. You eat your first bar on day 1, and then your last 2
bars on day 2. You won't have enough for day 3. Thus, you can eat for 2 days.
For test case 5, you have 6 ice cream bars. You eat 1 bar on day 1, 2 bars on day 2, and 3 bars
on day 3. You won't have enough for day 4. Thus, you can eat for 3 days.
For test case 6, you have 11 ice cream bars. You eat 1 bar on day 1, 2 bars on day 2, 3 bars on
day 3, and 4 bars on day 4. Since you only have 1 left, you won't have enough for day 5. Thus,
you can eat for 4 days.
Transcribed Image Text:Input Format The first line of input contains a positive integer T denoting the number of test cases that follow. Each test case is described in a single line containing a single integer N denoting the number of ice cream bars you have. Output Format For each test case, output a single line containing the number of days you can eat for before running out of ice cream bars and not being able to fully eat the next day. Constraints 1 ≤ T ≤ 100 Main Test Set 1 ≤ N≤ 105 Bonus Test Set 1 1 ≤ N≤ 1015 Careful! If you are a Java or C/C++ programmer, be aware that the int variable type may be too small to contain N! Java programmers can use variable types long or float instead, and likewise long long or float for C/C++. Bonus Test Set 2 1 ≤N≤ 1010000 Careful! Values of N in this test set are extremely large! They exceed the maximum values of 64 bit integers and floats. This one can be quite tricky to get right, so we recommend trying other problems first if you're stuck. Sample Test Cases Sample Input 9 0 1 2 3 6 11 69 Sample Output OHHN34 0 1 1 2 11 51 156 1337 12345 Sample Explanations For test case 1, For test case 1, you have no ice cream bars. You can't eat any at all. Thus, you can only eat for 0 days. For test case 2, you have 1 ice cream bar. You eat your only bar on day 1, and then won't have enough for day 2. Thus, you can only eat for 1 days. For test case 3, you have 2 ice cream bars. You eat your first bar on day 1, and then won't have enough for day 2 because you need 2 but only have 1 more. Thus, you can only eat for 1 day. For test case 4, you have 3 ice cream bars. You eat your first bar on day 1, and then your last 2 bars on day 2. You won't have enough for day 3. Thus, you can eat for 2 days. For test case 5, you have 6 ice cream bars. You eat 1 bar on day 1, 2 bars on day 2, and 3 bars on day 3. You won't have enough for day 4. Thus, you can eat for 3 days. For test case 6, you have 11 ice cream bars. You eat 1 bar on day 1, 2 bars on day 2, 3 bars on day 3, and 4 bars on day 4. Since you only have 1 left, you won't have enough for day 5. Thus, you can eat for 4 days.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY