Minimize Digit Sum codechef solution long challenge 100% correct solution

Let f(n,B)f(n,B) be the sum of digits of the integer nn when written in base BB. Given QQ queries, each consisting of three integers n,ln,l and rr. Find the value of BB corresponding to which f(n,B)f(n,B) is minimum for all l≤B≤rl≤B≤r. If there are multiple such values, you can print any of them. Input Format Minimize Digit Sum solution codechef The first line contains in single integer QQ, the … Read more

Minimum Digit Sum 2 codechef solution 100% correct solution

This problem is similar to the problem “MNDIGSUM”. The only differences are in the constraints and in the input format. In this problem the range for the base BB is [2,R][2,R], the value of nn can be upto 10121012 and the total number of queries is at most 300300. The differences are described in bold. Let f(n,B)f(n,B) be the sum of digits of … Read more

Minimize Digit Sum codechef solution 100% correct solution

Let f(n,B)f(n,B) be the sum of digits of the integer nn when written in base BB. Given QQ queries, each consisting of three integers n,ln,l and rr. Find the value of BB corresponding to which f(n,B)f(n,B) is minimum for all l≤B≤rl≤B≤r. If there are multiple such values, you can print any of them. Input Format Minimize Digit Sum solution codechef The first line contains in single integer QQ, the … Read more