Unable to debug what is wrong with the code

https://ide.codingblocks.com/#/s/13788

Getting sample test cases right , tried some other number as well , but not passing real test cases.

Provide the link of the question as well

Provide its Qn link .

Following is the question link.
https://hack.codingblocks.com/contests/c/255/68

Hey ! as constraints are very large you cannot traverse for all elements for ur array so u can think of simplifying the equation . What i mean to say is , that equation can be simplified to someconstant* n/2 +some_ohter_constant… Okay lets seee this

#include
#include
using namespace std;

int main() {
int n;
cin>>n;
while(n–){
long long int m;
cin>>m;
long long int a=(m%2==0)?m/2:(-1-m/2);
cout<<a<<endl;
}
}

1 Like