We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Manasa and Stones
Manasa and Stones
Sort by
recency
|
963 Discussions
|
Please Login in order to post a comment
import java.io.; import java.util.; import java.util.stream.*;
class Result {
}
public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
}
C++ ans
vector stones(int n, int a, int b) { if (n <= 1) { return {0}; }
}
My solution in C language :
The solution here is to use the absolute difference between the two differences to increment the initial value (0 + (smallest_value_between_a_and_b * (n-1))) until you reach the expected number of stones (initial value is the first stone).
We know the output as follow:
we can iterate over range 'n' and add these values to set remove duplicates.