My issue
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
/*
I don't know why my solution is incorrect?
explanation
for N=5, 5*6/2==sum and sum is even only if (5 and 5/2 is even) or (6 and 6/2 is even).
else n=n-1.
*/
int t;
cin>>t;
while(t--){
int N;
cin>>N;
while(N>=2){
if(N%2==0 && (N/2)%2==0){
cout<<N;break;
}
else if((N+1)%2==0 && ((N+1)/2)%2==0){
cout<<N;break;
}
N=N-1;
}
cout<<endl;
}
return 0;
}
Problem Link: CodeChef: Practical coding for everyone