Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- public class Main {
- public static void main(String[] args) throws Exception {
- BufferedReader r =new BufferedReader(new InputStreamReader(System.in));
- long t=Long.parseLong(r.readLine());
- while(t-->0)
- {
- String[] value=r.readLine().split(" ");
- long first=Long.parseLong(value[0]);
- long M=Long.parseLong(value[1]);
- long N=Long.parseLong(value[2]);
- long dist=Long.parseLong(value[3]);
- System.out.println(Math.abs(first*M+((dist-first)*N)));
- }
- }
- }
Add Comment
Please, Sign In to add comment