1077A codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
long long int t,a,b,k;
cin>>t;
while(t--)
{
cin>>a>>b>>k;
if(k%2==0)
{
a=a*(k/2);
b=b*(k/2);
cout<<a-b<<endl;
}
else
{
a=a*(k/2+1);
b=b*(k/2);
cout<<a-b<<endl;
}
}
return 0;
}
0 Comments