5 kyu
Simple Fun #294: Reduce Square Roots
34 of 59myjinxin2015
Description:
Task
Given a list of integers, define a move as taking one of the integers in the list and replacing it with its square root, rounded down to the nearest integer.
Given an integer l
and an integer k
, start with the array [1, 2, 3, ..., l]
and find the minimal sum of the array after k
moves.
Input/Output
[input]
integer l
1 ≤ l ≤ 10^4
[input]
integer k
The number of moves.
1 ≤ k ≤ 10^4
[output]
an integer
The minimal sum after k
moves.
Example
For l = 5 and k = 2
, the output should be 10
.
We start with [1, 2, 3, 4, 5]
.
After square rooting 5
to get [1, 2, 3, 4, 2]
and then square rooting 3
to get [1, 2, 1, 4, 2]
, we end up with a sum of 10
.
Algorithms
Similar Kata:
Stats:
Created | May 18, 2017 |
Published | May 18, 2017 |
Warriors Trained | 208 |
Total Skips | 3 |
Total Code Submissions | 269 |
Total Times Completed | 59 |
JavaScript Completions | 34 |
Python Completions | 27 |
Total Stars | 7 |
% of votes with a positive feedback rating | 91% of 17 |
Total "Very Satisfied" Votes | 15 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 3 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |