Help me in solving CHESSCOLOUR problem

My issue

include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int t ;
cin>>t;
for(int i =0;i<t;i++){
int n;
cin>>n;

    if(n%2 == 0) cout<<2<<endl;
    else cout<<(((n*n + 1)/2) + 1)<<endl;
}

}

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t ;
	cin>>t;
	for(int i =0;i<t;i++){
	    int n;
	    cin>>n;
	    
	    if(n%2 == 0) cout<<2<<endl;
	    else cout<<(((n*n + 1)/2) + 1)<<endl;
	}
}

Problem Link: Chess Colouring Practice Coding Problem