Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class asfd {
  4. public static void main(String[] args) {
  5. Scanner scan=new Scanner(System.in);
  6. int t=scan.nextInt();
  7. for(int tt=0;tt<t;tt++) {
  8. long a=scan.nextInt(), b=scan.nextInt(), k=scan.nextInt();
  9. long res=(a-b)*(k/2);
  10. // System.out.println(res);
  11. if(k%2==1) res+=a;
  12. System.out.println(res);
  13. }
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement