My issue
Why am I wrong here ?
My code
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while(t--)
{
long long int n;
long long int k;
cin >> n >> k;
if(n < 2*k - 1)
{
cout << n/2 << endl;
}
else if(n == 2*k - 1)
{
cout << (k-1)/2;
}
else
{
long long int x1 = n % k;
if(x1 == k-1)
{
cout << x1/2 << endl;;
}
else
{
x1 += k;
cout << x1/2 << endl;
}
}
}
return 0;
}
Problem Link: MAXIMALEXP Problem - CodeChef