B. Kill Demodogs
Demodogs from the Upside-down have attacked Hawkins again. El wants to reach Mike and also kill as many Demodogs in the way as possible.
Hawkins can be represented as an grid. The number of Demodogs in a cell at the -th row and the -th column is . El is at position of the grid, and she has to reach where she can find Mike.
The only directions she can move are the right (from to ) and the down (from to ). She can't go out of the grid, as there are doors to the Upside-down at the boundaries.
Calculate the maximum possible number of Demodogs she can kill on the way, considering that she kills all Demodogs in cells she visits (including starting and finishing cells).
Print modulo . Modulo because the result can be too large and multiplied by because we are never gonna see it again!
(Note, you firstly multiply by and only after that take the remainder.)
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains one integer () — the size of the grid.
For each test case, print a single integer — the maximum number of Demodogs that can be killed multiplied by , modulo .
code of this question ---
void solve()
{
int n;
cin >> n;
int ans = 2022/6;
ans*=n;
ans%=Mod;
ans*=n+1;
ans%=Mod;
ans*=4*n-1;
ans%=Mod;
cout<<ans<<nline;
}


No comments:
Post a Comment