Guest User

TAXIFARE Solution

a guest
Sep 18th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) throws Exception {
  7. BufferedReader r =new BufferedReader(new InputStreamReader(System.in));
  8.  
  9.  
  10. long t=Long.parseLong(r.readLine());
  11. while(t-->0)
  12. {
  13. String[] value=r.readLine().split(" ");
  14. long first=Long.parseLong(value[0]);
  15. long M=Long.parseLong(value[1]);
  16. long N=Long.parseLong(value[2]);
  17. long dist=Long.parseLong(value[3]);
  18.  
  19. System.out.println(Math.abs(first*M+((dist-first)*N)));
  20.  
  21. }
  22. }
  23.  
  24. }
Add Comment
Please, Sign In to add comment