Я получил этот вопрос как часть интервью, и я все еще не могу его решить. Это идет как этотПоиск минимального количества дней
A person has to complete N units of work; the nature of work is the same.
In order to get the hang of the work, he completes only one unit of work in the first day.
He wishes to celebrate the completion of work, so he decides to complete one unit of work in the last day.
Given that he is only allowed to complete x, x+1 or x-1 units of work in a day, where x is the units of work
completed on the previous day.
How many minimum days will he take to complete N units of work?
Sample Input:
6
-1
0
2
3
9
13
Here, line 1 represents the number of input test cases.
Sample Output:
0
0
2
3
5
7
Each number represents the minimum days required for each input in the sample input.
Я попытался сделать это, используя подход изменения монеты, но не был в состоянии сделать это.
Какое ограничение для N? –
@PhamTrung Это не было дано. Я думаю, если это отрицательно, просто верните 0. – Angersmash
Это не относится к stackoverflow, на мой взгляд, попробуйте поместить его в http://codegolf.stackexchange.com/ – Yerken