Advertisement
erfanul007

Untitled

Jan 17th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1.  
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. typedef long long int ll;
  6. typedef unsigned long long int ull;
  7. typedef vector<int> vi;
  8. typedef vector<ll> vll;
  9. typedef vector<vi> vvi;
  10. typedef pair<int,int> pii;
  11. typedef vector< pii > vpii;
  12. typedef set<int> sti;
  13.  
  14. #define pb push_back
  15. #define pob pop_back
  16. #define mp make_pair
  17. #define ff first
  18. #define ss second
  19. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  20. #define loop(i,y) for(int i=0; i<int(y); i++)
  21. #define rloop(i,y) for(int i=int(y); i>0; i--)
  22. #define rloop1(i,y) for(int i=int(y)-1; i>=0; i--)
  23. #define read() freopen("input.txt", "r", stdin)
  24. #define write() freopen("output.txt", "w", stdout)
  25. #define cspf(i) printf("Case %d: \n", i)
  26. #define all(v) v.begin(),v.end()
  27. #define rall(v) v.rbegin(),v.rend()
  28. /// Constants
  29. #define eps 1e-9
  30. #define PI acos(-1.0) // 3.1415926535897932
  31.  
  32. int main()
  33. {
  34. ll n;
  35. cin>>n;
  36. while(n--){
  37. ll a,b,k,x,y,sm;
  38. cin>>a>>b>>k;
  39. x=k%2;
  40. k/=2;
  41. y=a-b;
  42. sm=(y*k)+(x*a);
  43. cout<<sm<<endl;
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement