You are given an $$$n \times m$$$ grid. At first, all cells are white.
An "O" is a set of $$$10$$$ red cells with the following shape:

A "K" is a set of $$$8$$$ blue cells with the following shape:

Note: You cannot rotate or flip these two shapes.
Count different coloring schemes containing exactly $$$10$$$ red and $$$8$$$ blue cells, so that the grid contains exactly one "O" and one "K".
The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10$$$).
The only line of each testcase contains two space-separated integers $$$n,m$$$ ($$$1 \le n,m \le 50$$$).
It is guaranteed that the sum of $$$n$$$ and $$$m$$$ over all test cases does not exceed $$$50$$$, respectively.
For each test case, output a single integer, which is the number of different coloring schemes where exactly one "O" and one "K" can be placed in the grid.
54 61 15 77 511 22
2 0 24 0 21464
In the first case, the two schemes are shown below.
![]() | ![]() |
You are given an integer $$$n$$$.
For the integer $$$n$$$, a pair $$$(a,b)$$$ is considered cool only if:
For a given integer $$$n$$$, find the maximum value of $$$a \cdot b$$$ among all cool pairs $$$(a, b)$$$.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$), the number of test cases.
For each test case, the only line contains a single integer $$$n$$$$$$(2 \le n \le 10^9)$$$.
For each test case, print the maximum value of $$$a \cdot b$$$ for all cool pairs $$$(a, b)$$$.
4299961000000000
2 56 261632 288230375614840832
You are given an integer $$$n$$$.
For the integer $$$n$$$, a pair $$$(a,b)$$$ is considered cool only if:
For a given integer $$$n$$$, find the maximum value of $$$\gcd(a,b)$$$ among all cool pairs $$$(a, b)$$$. Here $$$\gcd$$$ means the greatest common divisor.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$), the number of test cases.
For each test case, the only line contains a single integer $$$n$$$ $$$(2 \le n \le 10^9)$$$.
For each test case, print the maximum value of $$$\gcd(a,b)$$$ for all cool pairs $$$(a, b)$$$.
92345678910
1 1 2 2 2 2 4 4 5
You are given $$$n$$$ tuples $$$(a_i,b_i)$$$. In the beginning, your score is $$$0$$$.
You can do the following operation any number of times in any order:
The first line contains a single integer $$$t$$$ ($$$1 \le t\le 10^4$$$), the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n\le 2 \cdot 10^5$$$).
The next $$$n$$$ lines of each test case contain two integers $$$a_i,b_i$$$ ($$$1\le a_i,b_i\le 10^9$$$).
It is guaranteed that the sum of $$$n$$$ for all tests does not exceed $$$2 \cdot 10^5$$$, and the answer for each test case won't exceed $$$9.2 \cdot 10^{18}$$$.
For each test case, output the maximum score you can get.
321 11000000000 100000000031 32 63 9685 6535 592 65789 2112 329 8
4000000004000000002 446 1220694
In the first case, we can do the following operations:
It can be proven that $$$4000000004000000002$$$ is the maximum of your score.
You can also do the following operations to get the maximum of your score:
You are given an array $$$a$$$ of size $$$n$$$.
An array $$$b$$$ of size $$$n$$$ is considered valid if and only if:
Count the number of different multisets $$$\{b_1,b_2,\ldots,b_n\}$$$ composed of each valid array $$$b$$$ modulo $$$998244353$$$.
Note that the order of numbers is not important in a multiset. For example, $$$\{1,1,2\}$$$ and $$$\{2,1,1\}$$$ are considered the same, but $$$\{1,1,2\}$$$ and $$$\{2,1,2\}$$$ are not.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 3 \cdot 10^5$$$).
The second line of each test case contains $$$n$$$ space separated integers $$$a_{i}$$$ ($$$1 \le a_{i} \le n-1$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.
For each test case, output in a new line — the number of different multisets $$$\{b_1,b_2,\ldots,b_n\}$$$ composed of each valid array $$$b$$$ modulo $$$998244353$$$.
621 132 2 232 1 241 2 3 243 3 2 263 3 2 2 3 3
3 1 6 0 12 60
In the first test case, there are four valid arrays — $$$[1,1]$$$,$$$[2,2]$$$,$$$[1,2]$$$ and $$$[2,1]$$$. Thus, there are three different multisets $$$\{1,1\}$$$,$$$\{2,2\}$$$ and $$$\{1,2\}$$$.
In the second test case, there is only one multiset $$$\{1,2,3\}$$$.
Given an integer array $$$a$$$ of length $$$n$$$, your task is to find the value of $$$\sum_{1 \le l \lt r \le n} \operatorname{MAD}([a_l,a_{l+1}, \ldots, a_r])$$$.
The $$$\operatorname{MAD}$$$ in an array is the largest value that appears at least twice in the array. If every value appears exactly once in the array, then its $$$\operatorname{MAD}$$$ value is $$$0$$$.
For example, $$$\operatorname{MAD}([1, 2, 2, 5, 5]) = 5$$$ and $$$\operatorname{MAD}([1, 2, 5]) = 0$$$.
The first line of the input contains exactly one integer, $$$t$$$ $$$(1 \le t \le 3 \cdot 10^4)$$$, the number of testcases.
The first line of each testcase contains exactly one integer, $$$n$$$ $$$(2 \le n \le 2 \cdot 10^5)$$$, the length of the array.
The second line of each testcase contains exactly $$$n$$$ integers, $$$a_1, a_2, ..., a_n$$$ $$$(1 \le a_i \le 10^8)$$$.
It is guaranteed that the sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ over all testcases.
For each test case, output an integer in a new line — $$$\sum_{1 \le l \lt r \le n} \operatorname{MAD}([a_l,a_{l+1}, \ldots, a_r])$$$.
321 244 2 2 485 2 1 2 1 5 2 1
0 10 40
In the first test case, $$$$$$\sum_{1 \le l \lt r \le n} \operatorname{MAD}([a_l,a_{l+1}, \ldots, a_r])=\operatorname{MAD}([a_1,a_2])=\operatorname{MAD}([1,2])=0. $$$$$$
In the second test case, the following table summarizes the $$$\operatorname{MAD}$$$ of each subarray. $$$$$$ \begin{array}{c|cccc} & 1 & 2 & 3 & 4 \\ \hline 1 & & 0 & 2 & 4 \\ 2 & & & 2 & 2 \\ 3 & & & & 0 \\ 4 & & & & \end{array} $$$$$$ The sum of all $$$\operatorname{MAD}$$$ values is $$$10$$$.
You are given a tree of size $$$n$$$ rooted at node $$$1$$$. At first, values of all nodes are equal to $$$0$$$.
Process $$$q$$$ queries of four types:
The first line contains two space-separated integers $$$n$$$ and $$$q$$$ $$$(2 \leq n,q \leq 3 \cdot 10^5)$$$, representing the number of nodes in the tree.
The following $$$n-1$$$ lines describe the edges of the tree. Each line contains two space-separated integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$), indicating an edge between nodes $$$u_i$$$ and $$$v_i$$$. It is guaranteed that the input data represents a tree.
The next $$$q$$$ lines describe the operations:
For each query of type $$$3$$$ or $$$4$$$, output the corresponding maximum value. Each result should be on a new line.
5 101 21 32 42 53 11 1 11 2 22 1 -53 24 13 12 2 -34 13 1
0 3 -2 3 -2 1