Загрузка...

#geeksforgeeks Candy Packets Problem in geeksforgeeks in C++ | Candy Packets

Source Code: https://drive.google.com/file/d/199fViOZoUhE9FqVdgAj-qetEk-tCTdNd/view?usp=sharing

Question link: https://practice.geeksforgeeks.org/problems/candy-packetssample-test-case-file-to-be-added/0

Question :
Ishaan has N candies with him. He wants to put them in packets. He can put 1 candy in the first packet, 2 candies in the second packet, 4 candies in the third and so on.
Calculate the minimum number of packets he needs to store all the candies if he fills the packets starting from the first packet.

Input :
First line of input contains a single integer T denoting the number of test cases.The only line of each test case contains an integer N.

Output :
For each test case, print the required answer in a new line.

Example :
Input :
3
2
4
7
Output :
2
3
3

Explanation :
Case 1 :
Put 1 candy in first packet.
Put 1 candy in second packet.
Case 2 :
Put 1 candy in first packet.
Put 2 candies in second packet.
Put 1 candy in third packet.
Case 3 :
Put 1 candy in first packet.
Put 2 candies in second packet.
Put 4 candy in third packet.

Видео #geeksforgeeks Candy Packets Problem in geeksforgeeks in C++ | Candy Packets канала Simple Snip Code
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять