My issue
When i want to work with 17 3,i can divide the stick in 3,3,3,3,3,2 which is not parity. Again in case of 19 5,i can divide the stick in 5,5,5,4. But in the most of the solutions they only checked if N is odd and X is even or not. But here we get “NO” for the odd odd case too. The code down below is the most liked code i picked. But can anyone explain the cases I asked?
My code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
ll n,x;
cin>>n>>x;
string ans="YES";
if(x%2==0 && (n%2)!=0)
{
ans="NO";
}
cout<<ans<<endl;
}
return 0;
}
Problem Link: Break the Stick Practice Coding Problem - CodeChef