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

Stats:

CreatedMay 18, 2017
PublishedMay 18, 2017
Warriors Trained208
Total Skips3
Total Code Submissions269
Total Times Completed59
JavaScript Completions34
Python Completions27
Total Stars7
% of votes with a positive feedback rating91% of 17
Total "Very Satisfied" Votes15
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments3
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • Voile Avatar
  • dfhwze Avatar
Ad