Вопрос задан 18.06.2023 в 14:55. Предмет Информатика. Спрашивает Коробьев Влад.

Омпания Microsony выпустила на рынок новую революционную игровую приставку BoxStation, и число

желающих приобрести её огромно! В день открытия продаж в магазин пришло N покупателей. Видя ажиотажный спрос, администрация договорилась, что в день открытия продаж в магазин поступят M приставок, и в последующие дни также будут подвозиться по M приставок ежедневно. Нераспроданные приставки остаются на складе в магазине и могут быть реализованы позже. Однако спрос на приставки оказался столь велик, что на второй день в магазин за приставками пришли N + 1 покупателей, на третий день — N + 2 покупателей и далее в каждый день покупателей было ровно на 1 больше, чем в предыдущий день. Каждому покупателю отпускается одна приставка. Но контракт с поставщиками приставок уже заключён, поэтому несмотря на рост спроса в магазин всё равно ежедневно привозят только M новых приставок. Определите, в какой день магазину не хватит приставок для того, чтобы удовлетворить запросы всех покупателей. Входные данные Первая строка входных данных содержит целое число N (1 ≤ N ≤ 109) — количество покупателей в первый день продаж. Вторая строка входных данных содержит целое число M (1 ≤ M ≤ 109) — количество ежеднево поставляемых в магазин приставок. Выходные данные Программа должна вывести одно целое число — номер дня, в который число покупателей в магазине превысит число доступных приставок. Система оценки Решения, правильно работающие, когда входные числа не превосходят 100, будут оцениваться в 60 баллов. Пример Ввод Вывод Пояснение 10 12 6 В первый день в магазин привезли 12 приставок, а пришло 10 покупателей, в конце дня в магазине осталось 2 приставки. На второй день привезли ещё 12 приставок, из них купили 11, поэтому в магазине осталось 2+12-11=3 приставки. На третий день привезли 12 приставок и пришло 12 покупателей, поэтому в магазине также осталось 3 приставки. На четвёртый день привезли 12 приставок, а купили 13, поэтому в магазине осталось 3+12-13=2 приставки. На пятый день привезли 12 приставок, а купили 14, поэтому в магазине не осталось ни одной приставки. Поэтому на шестой день магазин не сможет удовлетворить всех покупателей.
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Васильева Ахалия.

Ответ (Python):

b = int(input())

a = int(input())

left = 0

right = 2 * 10 ** 9 + 1

while right - left > 1:

   mid = (left + right) // 2

   plus = a * mid

   minus = (b + b + mid - 1) * mid // 2

   if plus >= minus:

       left = mid

   else:

       right = mid

print(right)

Объяснение:

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

The problem states that the company Microsony has released a new gaming console called BoxStation, and there is a huge demand for it. On the first day of sales, N customers arrived at the store. The store administration agreed that M consoles would be delivered on the first day of sales, and in the following days, M consoles would be delivered daily. Unsold consoles remain in the store's warehouse and can be sold later. However, the demand for consoles is so high that on the second day, N+1 customers arrived, on the third day N+2 customers arrived, and so on, with each day having one more customer than the previous day. Each customer is allowed to purchase only one console. The contract with the console suppliers has already been signed, so despite the increasing demand, only M new consoles are delivered daily. The task is to determine on which day the store will not have enough consoles to satisfy all the customers.

To solve this problem, we need to keep track of the number of consoles available in the store each day and compare it with the number of customers. If the number of customers exceeds the number of available consoles, we can determine the day when the store will not have enough consoles.

Let's go through an example to understand the problem better:

Input: N = 10 M = 12

On the first day, 12 consoles are delivered, and 10 customers arrive. At the end of the day, there are 2 consoles left in the store.

On the second day, 12 more consoles are delivered, making a total of 24 consoles available. However, 11 customers arrive, so only 11 consoles are sold. At the end of the day, there are 13 consoles left in the store.

On the third day, 12 more consoles are delivered, making a total of 25 consoles available. 12 customers arrive, and all the consoles are sold. At the end of the day, there are 3 consoles left in the store.

On the fourth day, 12 more consoles are delivered, making a total of 15 consoles available. However, 13 customers arrive, so only 13 consoles are sold. At the end of the day, there are 2 consoles left in the store.

On the fifth day, 12 more consoles are delivered, making a total of 14 consoles available. However, 14 customers arrive, so all the consoles are sold. At the end of the day, there are no consoles left in the store.

Therefore, on the sixth day, the store will not be able to satisfy all the customers.

To solve this problem programmatically, we can use a loop to iterate through each day and keep track of the number of available consoles. We can compare this number with the number of customers each day. Once the number of customers exceeds the number of available consoles, we can return the day as the answer.

Here's an example of how the solution could be implemented in Python:

```python def find_day_with_insufficient_consoles(N, M): available_consoles = M day = 1

while N > available_consoles: N += day available_consoles += M day += 1

return day

# Example usage N = 10 M = 12 result = find_day_with_insufficient_consoles(N, M) print(result) # Output: 6 ```

In this example, the `find_day_with_insufficient_consoles` function takes the number of customers on the first day (`N`) and the number of consoles delivered daily (`M`) as input. It then iterates through each day, incrementing the number of customers and available consoles accordingly. Once the number of customers exceeds the number of available consoles, it returns the day as the answer.

Please note that the solution provided here assumes that the input values are within the given constraints (N and M are between 1 and 10^9).

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос