CodeChef May Long Challenge Solution | Solubility (SOLBLTY) solution | AskTheCode
Solubility (SOLBLTY) solution
Problem:
Suppose for a unit rise in temperature, the solubility of sugar in water increases by B(g/100mL).
Chef does an experiment to check how much sugar (in g
) he can dissolve given that he initially has 1 liter of water at X degrees and the solubility of sugar at this temperature is A(g/100mL). Also, Chef doesn't want to lose any water so he can increase the temperature to at most 100 degrees.
Assuming no loss of water takes place during the process, find the maximum amount of sugar (in g
) can be dissolved in 1 liter of water under the given conditions.
Input:
The first line contains an integer T, the number of test cases. Then the test cases follow.
The only line of each test case contains three integers X,A,B.
Output:
For each testcase, output in a single line the answer to the problem.
Sample Input:
3
40 120 1
35 120 2
40 115 3
Sample Output:
1800
2500
2950
Explanation:

Code:
In Java:
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef{
public static void main (String[] args) throws java.lang.Exception{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
int X = sc.nextInt();
int A = sc.nextInt();
int B = sc.nextInt();
System.out.println((A+((100-X)*B))*10);
}
}
}
In C++:
Comentarios