Chef and walk

plz help why my code given wrong answer,???
#include <bits/stdc++.h>
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;cin>>t;
while(t–)
{
unsigned long long n,k,ans;
cin>>n>>k;
if(k%2==0)
{
ans=(n+((k/2)-1))(n+(k/2))+n;
}
else
{
ans=(n+(k/2))
(n+(k/2)+1)-n;
}
cout<<ans<<endl;
}
return 0;
}

you are not taking modulo at any step. This is one of the mistake

but test case given right answer,
plz help i can’t understand i can i use that in this case

for n=0. this won’t work.

Which test case, the sample? Of course modulo wouldn’t affect that, the answers are nowhere near 1 billion.

Here’s a case you’ll fail on:

1
1000000000 1000000000

expected answer: 750000119

Also, format your code or link the submission, because it’s literally impossible for us to debug it otherwise.

Ok but for large number like n = 10^9 and k = 10^9 it would result in very large number and integer overflow so what you need is do modulo m which will be given in question.

see this https://www.codechef.com/viewsolution/32361325